-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
174 lines (160 loc) · 5.51 KB
/
flake.nix
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
{
description = "A collection of Nix Flake Templates";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
systems.url = "github:nix-systems/default";
pre-commit-hooks.url = "github:cachix/git-hooks.nix";
cli = {
url = "github:nulladmin1/getflake";
inputs.systems.follows = "systems";
};
};
outputs = {
self,
nixpkgs,
systems,
pre-commit-hooks,
cli,
...
}: let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
pkgsFor = forEachSystem (system: import nixpkgs {inherit system;});
in {
checks = forEachSystem (system: {
pre-commit-run = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
actionlint.enable = true;
alejandra.enable = true;
editorconfig-checker.enable = true;
statix.enable = true;
nil.enable = true;
};
};
});
devShells = forEachSystem (system: {
default = pkgsFor.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-run) shellHook;
buildInputs = self.checks.${system}.pre-commit-run.enabledPackages;
};
});
templates = {
default = {
description = "Nix Flake Template for Development";
path = ./default;
};
go-nix = {
description = "Nix Flake Template for Go with Nixpkgs Builders";
path = ./go-nix;
};
python-nix = {
description = "Nix Flake Template for Python using Nixpkgs builders";
path = ./python-nix;
};
python-pyproject-nix = {
description = "Nix Flake Template for Python using Pyproject-nix";
path = ./python-pyproject-nix;
};
python-poetry = {
description = "Nix Flake Template for Python using Poetry";
path = ./python-poetry;
};
python-uv = {
description = "Nix Flake Template for Python using uv2nix";
path = ./python-uv;
};
rust-fenix-naersk = {
description = "Nix Flake Template for Rust using Fenix and Naersk";
path = ./rust-fenix-naersk;
};
rust-nix = {
description = "Nix Flake Template for Rust using Nixpkgs Builders";
path = ./rust-nix;
};
cpp-cmake = {
description = "Nix Flake Template for C++ using CMake";
path = ./cpp-cmake;
};
go-gomod2nix = {
description = "Nix Flake Template for Go using gomod2nix";
path = ./go-gomod2nix;
};
vimPlugins = {
description = "Nix Flake Template for vimPlugins";
path = ./vimPlugin;
};
flutter-nix = {
description = "Nix Flake Template for Flutter using Nixpkgs Builders";
path = ./flutter-nix;
};
nixpkgs = {
description = "Nix Flake Template for Nixpkgs Development";
path = ./nixpkgs;
};
bash = {
description = "Nix Flake Template for Bash using Nixpkgs Builders";
path = ./bash;
};
zig = {
description = "Nix Flake Template for Zig using Nixpkgs Builders";
path = ./zig;
};
bevy = {
description = "Nix Flake Template for Bevy using Fenix and Crane";
path = ./bevy;
};
rust-fenix-crane = {
description = "Nix Flake Template for Rust using Fenix and Crane";
path = ./rust-fenix-crane;
};
crane = self.templates.rust-fenix-crane;
sh = self.templates.bash;
flutter = self.templates.flutter-nix;
pyproject = self.templates.python-pyproject-nix;
python = self.templates.python-nix;
poetry = self.templates.python-poetry;
uv = self.templates.python-uv;
rust = self.templates.rust-fenix-crane;
cpp = self.templates.cpp-cmake;
go = self.templates.go-gomod2nix;
vim = self.templates.vimPlugins;
};
apps = forEachSystem (system: let
inherit (pkgsFor.${system}.lib) getExe;
jq = getExe pkgsFor.${system}.jq;
prettier = getExe pkgsFor.${system}.nodePackages.prettier;
in
cli.apps.${system}
// {
makeTable = {
type = "app";
program = getExe (pkgsFor.${system}.writeShellScriptBin "makeTable" ''
flake_templates=$(nix flake show --json | ${jq} '.templates')
table="| Type Keyword | Type | Subdirectory | Documentation |
|--------------|------|--------------|--------------|"
declare -A type_map
declare -A keywords_map
while IFS='@' read -r key desc; do
desc=$(echo "$desc" | xargs)
if [[ -z "''${type_map[$desc]:-}" ]] || [[ ''${#key} -gt ''${#type_map[$desc]} ]]; then
type_map["$desc"]="$key"
fi
if [[ -z "''${keywords_map[$desc]:-}" ]]; then
keywords_map["$desc"]="\`$key\`"
else
keywords_map["$desc"]="''${keywords_map[$desc]}, \`$key\`"
fi
done < <(echo "$flake_templates" | ${jq} -r 'to_entries | sort_by(.value.description)[] | "\(.key)@\(.value.description | sub("^Nix Flake Template for "; ""))"')
mapfile -t sorted_descriptions < <(printf "%s\n" "''${!type_map[@]}" | sort)
for desc in "''${sorted_descriptions[@]}"; do
keywords="''${keywords_map[$desc]}"
type="''${type_map[$desc]}"
table+="
| $keywords | $desc | [$type]($type) | [README]($type/README.md) |"
done
echo -e "$table" | ${prettier} --parser markdown
'');
};
});
};
}