main
1{
2 description = "System Config";
3
4 nixConfig = {
5 extra-substituters = [
6 "https://nixos-raspberrypi.cachix.org"
7 ];
8 extra-trusted-public-keys = [
9 "nixos-raspberrypi.cachix.org-1:4iMO9LXa8BqhU+Rpg6LQKiGa2lsNh/j2oiYLNOQ5sPI="
10 ];
11 };
12
13 outputs =
14 { self, ... }@inputs:
15 let
16 inherit (self) outputs;
17 stateVersion = "24.11";
18
19 libx = import ./lib {
20 inherit
21 self
22 inputs
23 outputs
24 stateVersion
25 ;
26 };
27
28 supportedSystems = [
29 "x86_64-linux"
30 "aarch64-linux"
31 ];
32 forAllSystems = inputs.nixpkgs.lib.genAttrs supportedSystems;
33 in
34 {
35 githubActions = inputs.nix-github-actions.lib.mkGithubMatrix {
36 checks = inputs.nixpkgs.lib.getAttrs [ "x86_64-linux" ] self.packages;
37 };
38 githubActionsMatrix = builtins.toJSON (
39 inputs.nixpkgs.lib.mapAttrsToList
40 (name: value: {
41 inherit name;
42 arch = value._module.specialArgs.system;
43 })
44 (
45 inputs.nixpkgs.lib.attrsets.filterAttrs (
46 _: config:
47 (
48 builtins.hasAttr "system" config._module.specialArgs && config._module.specialArgs.hostname != "foo"
49 )
50 ) self.nixosConfigurations
51 )
52 );
53 # Standalone home configurations
54 # FIXME set this up
55 homeConfigurations = {
56 # Fedora CSB workstations
57 "vdemeest@aomi" = libx.mkHome {
58 username = "vdemeest";
59 hostname = "aomi";
60 desktop = "niri";
61 };
62 "vdemeest@kyushu" = libx.mkHome {
63 username = "vdemeest";
64 hostname = "kyushu";
65 desktop = "niri";
66 };
67 "vincent@nagoya" = libx.mkHome {
68 username = "vincent";
69 hostname = "nagoya";
70 system = "aarch64-linux";
71 };
72 "vincent@sakhalin" = libx.mkHome {
73 username = "vincent";
74 hostname = "sakhalin";
75 standaloneFedora = true;
76 };
77 # headless machine
78 "vincent@aion" = libx.mkHome {
79 username = "vincent";
80 hostname = "aion";
81 system = "aarch64-linux";
82 };
83 "houbeb@aion" = libx.mkHome {
84 username = "houbeb";
85 hostname = "aion";
86 system = "aarch64-linux";
87 };
88 };
89 nixosConfigurations = {
90 # Laptop for LLM workloads (unstable)
91 okinawa = libx.mkHost {
92 hostname = "okinawa";
93 desktop = "niri"; # or "sway"
94 };
95 # Servers (unstable)
96 # sakhalin = libx.mkHost {
97 # hostname = "sakhalin";
98 # };
99 shikoku = libx.mkHost {
100 hostname = "shikoku";
101 pkgsInput = inputs.nixpkgs-26_05;
102 homeInput = inputs.home-manager-26_05;
103 agenixInput = inputs.agenix-26_05;
104 };
105 # Servers (stable)
106 aix = libx.mkHost {
107 hostname = "aix";
108 system = "aarch64-linux";
109 hardwareType = "rpi4";
110 pkgsInput = inputs.nixpkgs-26_05;
111 homeInput = inputs.home-manager-26_05;
112 agenixInput = inputs.agenix-26_05;
113 };
114 aion = libx.mkHost {
115 hostname = "aion";
116 system = "aarch64-linux";
117 pkgsInput = inputs.nixpkgs-26_05;
118 homeInput = inputs.home-manager-26_05;
119 agenixInput = inputs.agenix-26_05;
120 };
121 rhea = libx.mkHost {
122 hostname = "rhea";
123 system = "aarch64-linux";
124 pkgsInput = inputs.nixpkgs-26_05;
125 homeInput = inputs.home-manager-26_05;
126 agenixInput = inputs.agenix-26_05;
127 };
128 lutece = libx.mkHost {
129 hostname = "lutece";
130 pkgsInput = inputs.nixpkgs-26_05;
131 homeInput = inputs.home-manager-26_05;
132 agenixInput = inputs.agenix-26_05;
133 };
134 carthage = libx.mkHost {
135 hostname = "carthage";
136 pkgsInput = inputs.nixpkgs-26_05;
137 homeInput = inputs.home-manager-26_05;
138 agenixInput = inputs.agenix-26_05;
139 };
140 };
141
142 nixosModules = {
143 # provided modules (to be upstreamed)
144 wireguard-client = ./modules/wireguard/client.nix;
145 wireguard-server = ./modules/wireguard/server.nix;
146 govanityurl = ./modules/govanityurl;
147 gosmee = ./modules/gosmee;
148 rsync-replica = ./modules/rsync-replica;
149 microshift = ./modules/microshift;
150 harmonia = ./modules/harmonia;
151 praetorian = inputs.praetorian.nixosModules.praetorian;
152 };
153
154 # Fedora config files (no system-manager, just the useful files)
155 fedoraConfigs =
156 let
157 mkFedoraConfigs =
158 hostname:
159 let
160 pkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
161 globals = import ./globals.nix {
162 inherit (inputs.nixpkgs) lib;
163 inherit hostname;
164 };
165 fedoraLibx = import ./lib/functions.nix { inherit (inputs.nixpkgs) lib; };
166 in
167 import ./systems/common/fedora-work/gen-configs.nix {
168 inherit (inputs.nixpkgs) lib;
169 inherit pkgs globals hostname;
170 libx = fedoraLibx;
171 };
172 in
173 {
174 kyushu = mkFedoraConfigs "kyushu";
175 aomi = mkFedoraConfigs "aomi";
176 sakhalin =
177 let
178 pkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
179 globals = import ./globals.nix {
180 inherit (inputs.nixpkgs) lib;
181 hostname = "sakhalin";
182 };
183 fedoraLibx = import ./lib/functions.nix { inherit (inputs.nixpkgs) lib; };
184 in
185 import ./systems/sakhalin/gen-configs.nix {
186 inherit pkgs globals;
187 libx = fedoraLibx;
188 };
189 };
190
191 hostConfigs = {
192 nagoya =
193 let
194 pkgs = import inputs.nixpkgs { system = "aarch64-linux"; };
195 globals = import ./globals.nix {
196 inherit (inputs.nixpkgs) lib;
197 hostname = "nagoya";
198 };
199 hostLibx = import ./lib/functions.nix { inherit (inputs.nixpkgs) lib; };
200 in
201 import ./systems/nagoya/gen-configs.nix {
202 inherit pkgs globals;
203 libx = hostLibx;
204 };
205 };
206
207 images = {
208 # sdimages
209 aix =
210 (self.nixosConfigurations.aix.extendModules {
211 modules = [
212 "${inputs.nixpkgs-26_05}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
213 ];
214 }).config.system.build.sdImage;
215 };
216
217 overlays = import ./overlays { inherit inputs; };
218
219 packages = forAllSystems (
220 system:
221 let
222 pkgs = import inputs.nixpkgs {
223 system = system;
224 config.allowAliases = false;
225 overlays = [
226 self.overlays.additions
227 ];
228 };
229 skipDarwinPackages =
230 system: n:
231 if lib.strings.hasSuffix "darwin" system then !(lib.strings.hasPrefix "koff" n) else true;
232 inherit (inputs.nixpkgs) lib;
233 drvAttrs = builtins.filter (n: lib.isDerivation pkgs.${n} && skipDarwinPackages system n) (
234 builtins.attrNames (self.overlays.additions pkgs pkgs)
235 );
236 in
237 lib.listToAttrs (map (n: lib.nameValuePair n pkgs.${n}) drvAttrs)
238 // {
239 dns-zones =
240 let
241 globals = import ./globals.nix { };
242 dns = inputs.dns;
243 mkZoneFile =
244 zoneName: zoneFile:
245 pkgs.writeText "db.${zoneName}" (
246 dns.lib.toString zoneName (import zoneFile { inherit dns globals; })
247 );
248 in
249 pkgs.runCommand "dns-zones" { } ''
250 mkdir -p $out
251 cp ${mkZoneFile "sbr.pm" ./systems/common/services/dns/sbr.pm.nix} $out/db.sbr.pm
252 cp ${mkZoneFile "home" ./systems/common/services/dns/home.nix} $out/db.home
253 cp ${mkZoneFile "vpn" ./systems/common/services/dns/vpn.nix} $out/db.vpn
254 cp ${mkZoneFile "demeester.fr" ./systems/common/services/dns/demeester.fr.nix} $out/db.demeester.fr
255 cp ${mkZoneFile "192.168.1.in-addr.arpa" ./systems/common/services/dns/192.168.1.nix} $out/db.192.168.1
256 cp ${mkZoneFile "10.168.192.in-addr.arpa" ./systems/common/services/dns/192.168.10.nix} $out/db.192.168.10
257 cp ${mkZoneFile "10.100.0.in-addr.arpa" ./systems/common/services/dns/10.100.0.nix} $out/db.10.100.0
258 '';
259
260 wg-configs =
261 let
262 globals = import ./globals.nix { };
263 serverPubkey = globals.machines.carthage.net.vpn.pubkey;
264 endpoint = globals.net.vpn.endpoint;
265 mkWgConfig =
266 hostname:
267 let
268 machine = globals.machines.${hostname};
269 vpnIp = builtins.head machine.net.vpn.ips;
270 in
271 pkgs.writeText "wg0-${hostname}.conf" ''
272 [Interface]
273 Address = ${vpnIp}/32
274 PostUp = test -f /persist/wireguard/private.key && wg set %i private-key /persist/wireguard/private.key || true
275
276 [Peer]
277 PublicKey = ${serverPubkey}
278 Endpoint = ${endpoint}:51820
279 AllowedIPs = 10.100.0.0/24
280 PersistentKeepalive = 25
281 '';
282 in
283 pkgs.runCommand "wg-configs" { } ''
284 mkdir -p $out
285 cp ${mkWgConfig "aix"} $out/wg0-aix.conf
286 cp ${mkWgConfig "athena"} $out/wg0-athena.conf
287 cp ${mkWgConfig "demeter"} $out/wg0-demeter.conf
288 '';
289 }
290 );
291
292 checks = forAllSystems (system: {
293 pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
294 src = ./.;
295 # Run hooks on pre-push instead of pre-commit for less intrusive workflow
296 default_stages = [
297 "manual"
298 "pre-push"
299 ];
300 hooks = {
301 # go
302 gofmt.enable = true;
303 # golangci-lint.enable = true;
304 # nix
305 deadnix.enable = true;
306 nixfmt.enable = true;
307 # statix.enable = true;
308 # python
309 ruff.enable = true;
310 # shell
311 shellcheck = {
312 enable = true;
313 excludes = [ "dots/config/zsh/.*" ]; # zsh files use zsh-specific syntax
314 };
315 # emacs lisp - basic syntax checking
316 elisp-byte-compile = {
317 enable = false; # Disabled - causes issues with missing packages in pre-push hook
318 name = "Emacs Lisp byte-compile";
319 entry =
320 let
321 pkgs = import inputs.nixpkgs { system = system; };
322 # Create a wrapper that runs Emacs byte-compilation
323 elisp-check = pkgs.writeShellScript "elisp-check" ''
324 ${pkgs.emacs}/bin/emacs --batch \
325 --eval "(setq byte-compile-error-on-warn t)" \
326 -f batch-byte-compile "$@"
327 '';
328 in
329 toString elisp-check;
330 files = "\\.el$";
331 excludes = [
332 "dots/\\.config/emacs/old/.*"
333 "dots/\\.config/emacs/elpa/.*"
334 "dots/\\.config/emacs/transient/.*"
335 "dots/\\.config/emacs/eshell/.*"
336 "dots/\\.config/emacs/custom\\.el"
337 "dots/\\.config/emacs/\\.chatgpt-shell\\.el"
338 "dots/\\.config/emacs/site-lisp/.*"
339 "\\.dir-locals\\.el"
340 ];
341 };
342 };
343 };
344 });
345
346 devShells = forAllSystems (system: {
347 default =
348 let
349 pkgs = import inputs.nixpkgs {
350 system = system;
351 config.allowUnfree = true;
352 };
353 in
354 inputs.nixpkgs.legacyPackages.${system}.mkShell {
355 inherit (self.checks.${system}.pre-commit-check) shellHook;
356 buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
357 packages = [
358 pkgs.git
359 pkgs.prettier
360 pkgs.deadnix
361 pkgs.nixfmt
362 inputs.agenix.packages.${system}.default
363 ];
364 name = "home";
365 DIRENV_LOG_FORMAT = "";
366 };
367 });
368 };
369
370 inputs = {
371 # Flake for compatibility with non-flake commands
372 flake-compat = {
373 type = "github";
374 owner = "edolstra";
375 repo = "flake-compat";
376 flake = false;
377 };
378
379 buildkit-tekton = {
380 url = "github:vdemeester/buildkit-tekton";
381 inputs.nixpkgs.follows = "nixpkgs";
382 };
383 flake-parts.url = "github:hercules-ci/flake-parts";
384 go-org-readwise = {
385 url = "git+https://codeberg.org/vdemeester/go-org-readwise";
386 inputs.nixpkgs.follows = "nixpkgs";
387 inputs.flake-parts.follows = "flake-parts";
388 };
389 pass-run = {
390 url = "github:vdemeester/pass-run/v0.1.0";
391 inputs.nixpkgs.follows = "nixpkgs";
392 };
393 radian = {
394 url = "github:vdemeester/radian";
395 inputs.nixpkgs.follows = "nixpkgs";
396 inputs.flake-parts.follows = "flake-parts";
397 };
398
399 # nixpkgs
400 nixpkgs = {
401 type = "github";
402 owner = "NixOS";
403 repo = "nixpkgs";
404 ref = "nixos-unstable";
405 };
406 nixpkgs-26_05 = {
407 type = "github";
408 owner = "NixOS";
409 repo = "nixpkgs";
410 ref = "nixos-26.05";
411 };
412 nixpkgs-master.url = "github:nixos/nixpkgs/master";
413 nono = {
414 url = "github:nolabs-ai/nono/v0.78.0";
415 inputs.nixpkgs.follows = "nixpkgs";
416 };
417 nixpkgs-wip-consolidated = {
418 type = "github";
419 owner = "vdemeester";
420 repo = "nixpkgs";
421 ref = "wip-consolidated";
422 };
423 pre-commit-hooks.url = "github:cachix/git-hooks.nix";
424 pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
425 pre-commit-hooks.inputs.flake-compat.follows = "flake-compat";
426 # Home Manager
427 home-manager = {
428 type = "github";
429 owner = "nix-community";
430 repo = "home-manager";
431 inputs.nixpkgs.follows = "nixpkgs";
432 };
433 dns = {
434 url = "github:nix-community/dns.nix";
435 inputs.nixpkgs.follows = "nixpkgs";
436 };
437 home-manager-26_05 = {
438 type = "github";
439 owner = "nix-community";
440 repo = "home-manager";
441 ref = "release-26.05";
442 inputs.nixpkgs.follows = "nixpkgs-26_05";
443 };
444
445 emacs-overlay = {
446 url = "github:nix-community/emacs-overlay";
447 inputs.nixpkgs.follows = "nixpkgs";
448 inputs.nixpkgs-stable.follows = "nixpkgs-26_05";
449 };
450
451 nixos-hardware = {
452 type = "github";
453 owner = "NixOS";
454 "repo" = "nixos-hardware";
455 };
456
457 # Me :D
458 chick-group = {
459 type = "github";
460 owner = "vdemeester";
461 repo = "chick-group";
462 inputs.nixpkgs.follows = "nixpkgs";
463 inputs.flake-parts.follows = "flake-parts";
464 inputs.pre-commit-hooks.follows = "pre-commit-hooks";
465 };
466 # Red Hat
467 chapeau-rouge = {
468 type = "github";
469 owner = "vdemeester";
470 repo = "chapeau-rouge";
471 inputs.nixpkgs.follows = "nixpkgs";
472 inputs.flake-parts.follows = "flake-parts";
473 inputs.pre-commit-hooks.follows = "pre-commit-hooks";
474 };
475 agenix.url = "github:ryantm/agenix";
476 agenix.inputs.nixpkgs.follows = "nixpkgs";
477 agenix.inputs.home-manager.follows = "home-manager";
478 agenix-26_05.url = "github:ryantm/agenix";
479 agenix-26_05.inputs.nixpkgs.follows = "nixpkgs-26_05";
480 agenix-26_05.inputs.home-manager.follows = "home-manager-26_05";
481
482 nix-cachyos-kernel = {
483 url = "github:xddxdd/nix-cachyos-kernel";
484 inputs.nixpkgs.follows = "nixpkgs";
485 };
486
487 lanzaboote.url = "github:nix-community/lanzaboote";
488 lanzaboote.inputs.nixpkgs.follows = "nixpkgs";
489
490 disko.url = "github:nix-community/disko";
491 disko.inputs.nixpkgs.follows = "nixpkgs";
492
493 harmonia.url = "github:nix-community/harmonia";
494 harmonia.inputs.nixpkgs.follows = "nixpkgs";
495
496 nix-github-actions.url = "github:nix-community/nix-github-actions";
497 nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
498
499 nixos-raspberrypi.url = "github:nvmd/nixos-raspberrypi/develop";
500 nixos-raspberrypi.inputs.nixpkgs.follows = "nixpkgs";
501 nixos-raspberrypi.inputs.flake-compat.follows = "flake-compat";
502
503 llm-agents.url = "github:numtide/llm-agents.nix";
504 llm-agents.inputs.nixpkgs.follows = "nixpkgs";
505 llm-agents.inputs.flake-parts.follows = "flake-parts";
506
507 voxtype.url = "github:peteonrails/voxtype/main";
508 voxtype.inputs.nixpkgs.follows = "nixpkgs";
509
510 praetorian.url = "github:vdemeester/praetorian/v2.0.0-rc2";
511 praetorian.inputs.nixpkgs.follows = "nixpkgs";
512 };
513}