feat(templates): add cmake-c
This commit is contained in:
@@ -238,6 +238,10 @@
|
|||||||
Before running nix build, make sure to run `cargo generate-lockfile` first.
|
Before running nix build, make sure to run `cargo generate-lockfile` first.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
cmake-c = {
|
||||||
|
path = ./templates/cmake-c;
|
||||||
|
description = "A simple cmake c project.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
1
templates/cmake-c/.gitignore
vendored
Normal file
1
templates/cmake-c/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
build
|
||||||
10
templates/cmake-c/CMakeLists.txt
Normal file
10
templates/cmake-c/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
project(Hello
|
||||||
|
DESCRIPTION "Hello World"
|
||||||
|
LANGUAGES C
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(hello src/main.c)
|
||||||
|
|
||||||
|
install(TARGETS hello)
|
||||||
56
templates/cmake-c/flake.nix
Normal file
56
templates/cmake-c/flake.nix
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
description = "Cmake C Flake";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = inputs @ {
|
||||||
|
self,
|
||||||
|
flake-parts,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
flake-parts.lib.mkFlake {inherit inputs;} (
|
||||||
|
top: {
|
||||||
|
imports = [];
|
||||||
|
|
||||||
|
flake = {
|
||||||
|
overlays.default = final: prev: {
|
||||||
|
my-derivation = final.callPackage ./nix/derivation.nix {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
|
|
||||||
|
perSystem = {
|
||||||
|
self',
|
||||||
|
pkgs,
|
||||||
|
system,
|
||||||
|
...
|
||||||
|
}: {
|
||||||
|
_module.args.pkgs = import inputs.nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [self.overlays.default];
|
||||||
|
};
|
||||||
|
|
||||||
|
packages.default = pkgs.my-derivation;
|
||||||
|
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
packages = [
|
||||||
|
pkgs.cmake-language-server
|
||||||
|
pkgs.cmake-format
|
||||||
|
pkgs.clang-tools
|
||||||
|
pkgs.gdb
|
||||||
|
];
|
||||||
|
inputsFrom = [self'.packages.default];
|
||||||
|
shellHook = ''
|
||||||
|
export CMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
17
templates/cmake-c/nix/derivation.nix
Normal file
17
templates/cmake-c/nix/derivation.nix
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
cmake,
|
||||||
|
stdenv,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
|
pname = "my-derivation";
|
||||||
|
version = "0.1.0";
|
||||||
|
src = ../.;
|
||||||
|
nativeBuildInputs = [cmake];
|
||||||
|
buildInputs = [];
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
description = "Hello World Binary";
|
||||||
|
mainProgram = "hello";
|
||||||
|
};
|
||||||
|
})
|
||||||
6
templates/cmake-c/src/main.c
Normal file
6
templates/cmake-c/src/main.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
puts("Hello, Flake!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user