feat(c): init c template
This commit is contained in:
parent
8e52914770
commit
01bc222af3
7 changed files with 108 additions and 0 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -4,3 +4,6 @@
|
||||||
**/result-*
|
**/result-*
|
||||||
**/.direnv
|
**/.direnv
|
||||||
**/dist
|
**/dist
|
||||||
|
**/*.*~
|
||||||
|
**/.\#*
|
||||||
|
**/\#*\#
|
27
templates/c/flake.lock
generated
Normal file
27
templates/c/flake.lock
generated
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1738680400,
|
||||||
|
"narHash": "sha256-ooLh+XW8jfa+91F1nhf9OF7qhuA/y1ChLx6lXDNeY5U=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "799ba5bffed04ced7067a91798353d360788b30d",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
28
templates/c/flake.nix
Normal file
28
templates/c/flake.nix
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
description = "REPLACE_DESC";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
}: let
|
||||||
|
inherit (nixpkgs) lib;
|
||||||
|
forAllSystems = f:
|
||||||
|
lib.genAttrs ["x86_64-linux" "aarch64-linux"] (system:
|
||||||
|
f {
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
in {
|
||||||
|
packages = forAllSystems ({pkgs}: {
|
||||||
|
default = pkgs.callPackage ./flake/default.nix {};
|
||||||
|
REPLACE_ME = self.packages.${pkgs.system}.default;
|
||||||
|
});
|
||||||
|
|
||||||
|
formatter = forAllSystems ({pkgs}: pkgs.callPackage ./flake/formatter.nix {});
|
||||||
|
};
|
||||||
|
}
|
25
templates/c/flake/default.nix
Normal file
25
templates/c/flake/default.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
stdenv,
|
||||||
|
lib,
|
||||||
|
meson,
|
||||||
|
ninja,
|
||||||
|
}:
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
pname = "REPLACE_ME";
|
||||||
|
version = "1";
|
||||||
|
|
||||||
|
src = lib.cleanSourceWith {
|
||||||
|
src = ../.;
|
||||||
|
filter = path: _type: baseNameOf path != ".git";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
meson
|
||||||
|
ninja
|
||||||
|
];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
mv timesave $out/bin
|
||||||
|
'';
|
||||||
|
}
|
20
templates/c/flake/formatter.nix
Normal file
20
templates/c/flake/formatter.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
writeShellApplication,
|
||||||
|
alejandra,
|
||||||
|
llvmPackages_19,
|
||||||
|
fd,
|
||||||
|
}:
|
||||||
|
writeShellApplication {
|
||||||
|
name = "formatter";
|
||||||
|
runtimeInputs = [
|
||||||
|
alejandra
|
||||||
|
llvmPackages_19.clang-tools
|
||||||
|
fd
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
fd --extension nix -X alejandra -- {}
|
||||||
|
fd --extension nix -X deadnix -e -- {}
|
||||||
|
fd --extension nix -x statix fix -- {}
|
||||||
|
fd --extension c -X clang-format --verbose -i -- {}
|
||||||
|
'';
|
||||||
|
}
|
3
templates/c/main.c
Normal file
3
templates/c/main.c
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void) { printf("Hello, world!\n"); }
|
2
templates/c/meson.build
Normal file
2
templates/c/meson.build
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
project('REPLACE_ME', 'c')
|
||||||
|
executable('REPLACE_ME', 'main.c')
|
Loading…
Add table
Add a link
Reference in a new issue