This repository has no description
16 kB
419 lines
1{
2 description = "lassulus superconfig";
3
4 inputs = {
5 # tracking nixos-unstable; if a bump lands an uncached firefox-devedition (beta channel
6 # isn't channel-gating on Hydra) it builds from source. Check first: s firefox-devedition-watch
7 # then pin a cached rev here if needed: github:nixos/nixpkgs/<rev>
8 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
9 # nixpkgs.url = "github:lassulus/nixpkgs/nixos-unstable";
10 # nixpkgs.url = "path:/home/lass/tmp/nixpkgs-disk-debug";
11 # nixpkgs.url = "git+file:/home/lass/src/nixpkgs";
12 # nixpkgs.url = "git+file:/Users/lassulus/src/nixpkgs";
13
14 nix-index-database.url = "github:nix-community/nix-index-database";
15 nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
16
17 nixvim.url = "github:nix-community/nixvim";
18 nixvim.inputs.nixpkgs.follows = "nixpkgs";
19
20 # git.clan.lol is unreachable; use the GitHub mirrors.
21 clan-core.url = "github:clan-lol/clan-core";
22 # clan-core.url = "path:/Users/lassulus/src/clan/clan-core";
23 # clan-core.url = "path:/home/lass/src/clan/clan-core";
24 clan-core.inputs.nixpkgs.follows = "nixpkgs";
25 clan-core.inputs.disko.follows = "disko";
26 clan-core.inputs.nix-select.url = "github:clan-lol/nix-select";
27 # data-mesher has no GitHub mirror. "" makes clan-core use this flake as
28 # data-mesher; see the empty flake.nixosModules.data-mesher below.
29 clan-core.inputs.data-mesher.follows = "";
30
31 stockholm.url = "git+https://github.com/krebs/stockholm?submodules=1";
32 # stockholm.url = "git+https://cgit.lassul.us/stockholm";
33 # stockholm.url = "path:/home/lass/sync/stockholm";
34 stockholm.inputs.nixpkgs.follows = "nixpkgs";
35 stockholm.inputs.buildbot-nix.follows = "";
36
37 # Host database only (modules/retiolum/hosts.nix), on every platform.
38 # The daemon is pkgs/tincr everywhere; barnacle imports tincr's own
39 # darwin module below, not kartei's retiolum shim.
40 kartei.url = "github:krebs/kartei";
41 kartei.inputs.nixpkgs.follows = "nixpkgs";
42 kartei.inputs.tincr.follows = "tincr";
43 kartei.inputs.crane.follows = "tincr/crane";
44 kartei.inputs.fenix.follows = "tincr/fenix";
45
46 # Only for darwinModules.tincr (launchd plumbing); the package comes
47 # from pkgs/tincr, which pins the same fork branch.
48 tincr.url = "github:Lassulus/tincr/lassulus/fixes";
49 tincr.inputs.nixpkgs.follows = "nixpkgs";
50 tincr.inputs.treefmt-nix.follows = "treefmt-nix";
51
52 disko.url = "github:nix-community/disko";
53 # disko.url = "path:/home/lass/src/disko/";
54 disko.inputs.nixpkgs.follows = "nixpkgs";
55
56 nixos-hardware.url = "github:nixos/nixos-hardware";
57
58 nether.url = "github:krebs/nether";
59 # nether.url = "git+file:/home/lass/src/nether";
60 nether.inputs.nixpkgs.follows = "nixpkgs";
61 nether.inputs.clan-core.follows = "clan-core";
62 nether.inputs.data-mesher.follows = "";
63
64 spora.url = "github:krebs/spora";
65 # spora.url = "git+file:/home/lass/src/spora";
66 spora.inputs.nixpkgs.follows = "nixpkgs";
67
68 nix-darwin.url = "github:LnL7/nix-darwin";
69 nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
70
71 nix-rosetta-builder.url = "github:cpick/nix-rosetta-builder";
72 nix-rosetta-builder.inputs.nixpkgs.follows = "nixpkgs";
73
74 nixos-facter.url = "github:numtide/nixos-facter-modules";
75
76 treefmt-nix.url = "github:numtide/treefmt-nix";
77 treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
78
79 le_menu.url = "github:lassulus/le_menu";
80 # le_menu.url = "git+file:/home/lass/src/le_menu";
81 le_menu.inputs.nixpkgs.follows = "nixpkgs";
82
83 extra-container.url = "github:erikarvstedt/extra-container";
84 extra-container.inputs.nixpkgs.follows = "nixpkgs";
85
86 llm-agents.url = "github:numtide/llm-agents.nix";
87 llm-agents.inputs.nixpkgs.follows = "nixpkgs";
88
89 hermes-agent.url = "github:nousresearch/hermes-agent";
90 hermes-agent.inputs.nixpkgs.follows = "nixpkgs";
91
92 nixpkgs-triage.url = "github:Lassulus/nixpkgs-triage";
93 nixpkgs-triage.inputs.nixpkgs.follows = "nixpkgs";
94
95 wrappers.url = "github:lassulus/wrappers";
96 # wrappers.url = "git+file:/home/lass/src/wrappers";
97 wrappers.inputs.nixpkgs.follows = "nixpkgs";
98
99 nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
100 nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs";
101
102 sigexec.url = "git+https://git.geninf.io/Lassulus/sigexec";
103 sigexec.inputs.nixpkgs.follows = "nixpkgs";
104
105 # build farm (configs/nix-farm): remote builds over grpc:// ...
106 nix-grpc-store.url = "github:Mic92/nix-grpc-store";
107 nix-grpc-store.inputs.nixpkgs.follows = "nixpkgs";
108 nix-grpc-store.inputs.niks3.follows = "niks3";
109
110 # ... and the S3-backed binary cache the outputs land in. Fork for
111 # `push --ignore-upstream-key` (not upstream yet). It rebases onto
112 # Mic92/niks3 daily (its .github/workflows/rebase-upstream.yml), so
113 # `nix flake update niks3` follows upstream.
114 niks3.url = "github:lassulus/niks3";
115 niks3.inputs.nixpkgs.follows = "nixpkgs";
116 niks3.inputs.treefmt-nix.follows = "treefmt-nix";
117
118 };
119
120 outputs =
121 inputs@{
122 self,
123 nixpkgs,
124 clan-core,
125 ...
126 }:
127 let
128 clan = clan-core.lib.clan {
129 self = self;
130 specialArgs.self = self;
131 modules = import ./clan_modules { inherit nixpkgs; };
132 vars.settings.secretStore = "password-store";
133 meta.domain = "s";
134 inventory = {
135 meta.name = "superconfig";
136 machines = {
137 ignavia.tags = [
138 "laptop"
139 "focus"
140 ];
141 mors.tags = [
142 "laptop"
143 "focus"
144 ];
145 aergia.tags = [
146 "laptop"
147 "focus"
148 ];
149 barnacle = {
150 machineClass = "darwin";
151 tags = [
152 "laptop"
153 "focus"
154 ];
155 };
156 icarus.tags = [ "laptop" ];
157 neoprism.tags = [ "server" ];
158 starkstrom = {
159 tags = [ "server" ];
160 deploy.forwardAgent = true;
161 };
162 acheron.tags = [ "server" ];
163 };
164 instances = {
165 tor = {
166 roles.server.tags.all = { };
167 };
168 retiolum = {
169 module.input = "self";
170 roles.default.tags.nixos = { };
171 };
172 internet = {
173 roles.default.machines = {
174 neoprism.settings.host = "neoprism.lassul.us";
175 neoprism.settings.port = 45621;
176 starkstrom.settings.host = "194.110.87.67";
177 starkstrom.settings.port = 45621;
178 };
179 };
180 state-version = {
181 module.name = "importer";
182 roles.default.tags.all = { };
183 roles.default.settings.extraModules = [
184 {
185 clan.core.state-version.enable = true;
186 }
187 ];
188 };
189 yggdrasil = {
190 roles.default.tags.nixos = { };
191 };
192 tor-yggdrasil = {
193 module.name = "tor";
194 roles.client.tags.nixos = { };
195 roles.server.tags.nixos = { };
196 roles.server.settings = {
197 secretHostname = false;
198 portMapping = [
199 {
200 # tcp
201 port = 6443;
202 target.port = 6443;
203 }
204 {
205 # tls
206 port = 6446;
207 target.port = 6443;
208 }
209 ];
210 };
211 };
212 };
213 };
214 machines =
215 nixpkgs.lib.mapAttrs
216 (machineName: _: {
217 imports = [
218 ./machines/${machineName}/physical.nix
219 ];
220 })
221 (
222 nixpkgs.lib.filterAttrs (
223 machineName: _: builtins.pathExists ./machines/${machineName}/physical.nix
224 ) (builtins.readDir ./machines)
225 );
226 };
227 in
228 clan-core.inputs.flake-parts.lib.mkFlake { inherit inputs; } {
229 systems = [
230 "x86_64-linux"
231 "aarch64-linux"
232 "aarch64-darwin"
233 "x86_64-darwin"
234 ];
235 imports = [
236 ./formatter.nix
237 ./pkgs/flake-module.nix
238 ./keys/flake-module.nix
239 ./retiolum/flake-module.nix
240 ./skills/flake-module.nix
241
242 ./wrapperModules/pi/flake-module.nix
243 ./wrapperModules/claude-code/flake-module.nix
244 ./wrapperModules/noctalia-shell/flake-module.nix
245 {
246 options.flake.wrapperModules = nixpkgs.lib.mkOption {
247 type = nixpkgs.lib.types.lazyAttrsOf nixpkgs.lib.types.raw;
248 default = { };
249 };
250 }
251 ]
252 ++ (
253 # Auto-import all flake-module.nix files from tools subdirectories
254 let
255 toolDirs = builtins.attrNames (
256 nixpkgs.lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./tools)
257 );
258 in
259 map (dir: ./tools + "/${dir}/flake-module.nix") toolDirs
260 );
261 flake.nixosConfigurations = clan.config.nixosConfigurations;
262 flake.clanInternals = clan.config.clanInternals;
263 flake.darwinConfigurations = clan.config.darwinConfigurations;
264 flake.clan = clan.config;
265 # clan-core imports data-mesher's module unconditionally; we don't run
266 # data-mesher or dm-dns, so an empty module stands in for it.
267 flake.nixosModules.data-mesher = { };
268
269 # Container configurations for use with extra-container
270 # Auto-discovers machines with container.nix
271 flake.containerConfigurations =
272 nixpkgs.lib.mapAttrs
273 (machineName: _: import ./machines/${machineName}/container.nix { inherit self; })
274 (
275 nixpkgs.lib.filterAttrs (
276 machineName: _: builtins.pathExists ./machines/${machineName}/container.nix
277 ) (builtins.readDir ./machines)
278 );
279
280 perSystem =
281 {
282 lib,
283 pkgs,
284 system,
285 ...
286 }:
287 {
288 packages = {
289 default = inputs.le_menu.lib.buildMenu {
290 inherit pkgs;
291 menuConfig = {
292 vim.run = "nix run ${self}#nvim";
293 shell.run = "nix run ${self}#shell";
294 machines.submenu = lib.mapAttrs (name: _machine: {
295 submenu.ssh.submenu = {
296 retiolum.run = "ssh -t ${name}.r";
297 spora.run = "ssh ${name}.s";
298 nether.run = "ssh ${name}.n";
299 tor.run = "torify ssh $(pass show machines/${name}/tor-hostname)";
300 };
301 }) self.nixosConfigurations;
302 debug.run = "env";
303 };
304 };
305 clan-cli = clan-core.packages.${system}.clan-cli;
306 }
307 // lib.mapAttrs' (
308 name: containerConfig:
309 lib.nameValuePair "container-${name}" (
310 inputs.extra-container.lib.buildContainers {
311 inherit system;
312 nixpkgs = inputs.nixpkgs;
313 config = {
314 # Workaround: extra-container's minimal module set doesn't
315 # include nixos-init.nix, but systemd.nix now references
316 # config.system.nixos-init.package for env-generator.
317 # Provide a dummy option until extra-container is updated.
318
319 imports = [
320 (
321 { pkgs, lib, ... }:
322 {
323 options.system.nixos-init.package = lib.mkPackageOption pkgs "nixos-init" { };
324 options.time.timeZone = lib.mkOption {
325 type = lib.types.nullOr lib.types.str;
326 default = null;
327 description = "Dummy option for extra-container compatibility";
328 };
329 options.services.openssh = {
330 enable = lib.mkOption {
331 type = lib.types.bool;
332 default = false;
333 description = "Dummy option for extra-container compatibility";
334 };
335 package = lib.mkPackageOption pkgs "openssh" { };
336 };
337 # systemd.nix sets environment.variables.SYSTEMD_XKB_DIRECTORY,
338 # but the minimal module set omits config/system-environment.nix
339 # which declares the option.
340 options.environment.variables = lib.mkOption {
341 type = lib.types.attrsOf lib.types.anything;
342 default = { };
343 description = "Dummy option for extra-container compatibility";
344 };
345 # systemd.nix reads config.i18n.imperativeLocale, but the
346 # minimal module set omits config/i18n.nix which declares it.
347 options.i18n.imperativeLocale = lib.mkOption {
348 type = lib.types.bool;
349 default = true;
350 description = "Dummy option for extra-container compatibility";
351 };
352 # nixos-containers.nix reads config.nix.enable and
353 # config.nix.daemon.enable for the /nix/var/nix bind
354 # mounts, but the minimal module set omits
355 # config/nix.nix which declares them.
356 options.nix = {
357 enable = lib.mkOption {
358 type = lib.types.bool;
359 default = true;
360 description = "Dummy option for extra-container compatibility";
361 };
362 daemon.enable = lib.mkOption {
363 type = lib.types.bool;
364 default = true;
365 description = "Dummy option for extra-container compatibility";
366 };
367 };
368 }
369 )
370 ];
371 containers.${name} = containerConfig;
372 };
373 }
374 )
375 ) self.containerConfigurations;
376 devShells.default = pkgs.mkShell {
377 packages = [
378 self.packages.${pkgs.system}.pass
379 (self.legacyPackages.${system}.bin_shim {
380 name = "clan";
381 pkg_name = "clan-cli";
382 })
383 ];
384 };
385 # orca: see pkgs/orca (darwin launcher fix).
386 legacyPackages.llm =
387 inputs.llm-agents.packages.${system}
388 // lib.optionalAttrs (self.packages.${system} ? orca) { inherit (self.packages.${system}) orca; };
389 checks =
390 let
391 # Check NixOS configurations can be evaluated (without building)
392 nixosChecks = lib.mapAttrs' (
393 name: config:
394 lib.nameValuePair "nixos-${name}" (
395 pkgs.runCommand "eval-${name}" { } ''
396 # Force evaluation of the toplevel path without building
397 echo "Evaluating ${name}: ${builtins.unsafeDiscardStringContext config.config.system.build.toplevel.drvPath}"
398 touch $out
399 ''
400 )
401 ) (lib.filterAttrs (_: config: config.pkgs.system == system) self.nixosConfigurations);
402
403 # Check Darwin configurations can be evaluated (without building)
404 darwinChecks = lib.mapAttrs' (
405 name: config:
406 lib.nameValuePair "darwin-${name}" (
407 pkgs.runCommand "eval-darwin-${name}" { } ''
408 # Force evaluation of the system path without building
409 echo "Evaluating ${name}: ${builtins.unsafeDiscardStringContext config.system.drvPath}"
410 touch $out
411 ''
412 )
413 ) (lib.filterAttrs (_: config: config.pkgs.system == system) self.darwinConfigurations);
414 in
415 nixosChecks // darwinChecks;
416 };
417 flake.lib = import ./lib { inherit (nixpkgs) lib; };
418 };
419}