-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
106 lines (93 loc) · 2.63 KB
/
Copy pathflake.nix
File metadata and controls
106 lines (93 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{
description = "A collection of templates from FalconProgrammer - Jonathan Boyle";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nix-precommit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = {
self,
nixpkgs,
flake-utils,
nix-precommit-hooks,
...
}:
{
templates = {
python-pdm = {
path = ./python-pdm;
description = "A template for a python project using pdm";
};
python-shell = {
path = ./python-shell;
description = "A template to create a python shell with certain packages";
};
python-poetry2nix = {
path = ./python-poetry2nix;
description = "A template for a python project using poetry2nix";
};
python-uv = {
path = ./python-uv;
description = "A template for Python development with uv/pip and virtual environments";
};
rust = {
path = ./rust;
description = "A template for Rust development with Nix";
};
default-package-flake = {
path = ./default-package-flake;
description = "A basic flake for building a default.nix package";
};
rust-bevy = {
path = ./rust-bevy;
description = "A NixOS development flake for Bevy development.";
};
ocaml = {
path = ./ocaml;
description = "A template for OCaml development with opam-nix";
};
clojure = {
path = ./clojure;
description = "A template for Closure development";
};
};
}
// flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
pre-commit-check =
nix-precommit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra-with-config = {
enable = true;
name = "alejandra";
entry = "${pkgs.alejandra}/bin/alejandra --experimental-config ./alejandra.toml";
language = "system";
files = "\\.nix$";
pass_filenames = true;
};
trim-trailing-whitespace.enable = true;
end-of-file-fixer.enable = true;
};
};
claude-pre-commit-hook =
pkgs.writeShellScriptBin "claude-pre-commit-check" ''
file_path=$(${pkgs.jq}/bin/jq -r '.tool_input.file_path // empty')
if [[ -z "$file_path" ]] || [[ ! -f "$file_path" ]]; then
exit 0
fi
# Run pre-commit on the specific file
${pkgs.pre-commit}/bin/pre-commit run --files "$file_path" 2>&1 || exit 2
'';
in {
devShells.default =
pkgs.mkShell {
inherit (pre-commit-check) shellHook;
buildInputs = with pkgs; [
alejandra
nixfmt-rfc-style
claude-pre-commit-hook
];
};
});
}