This repository has no description
13 kB
359 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 clan-core.url = "git+https://git.clan.lol/clan/clan-core";
21 # clan-core.url = "path:/Users/lassulus/src/clan/clan-core";
22 # clan-core.url = "path:/home/lass/src/clan/clan-core";
23 clan-core.inputs.nixpkgs.follows = "nixpkgs";
24 clan-core.inputs.disko.follows = "disko";
25
26 stockholm.url = "git+https://github.com/krebs/stockholm?submodules=1";
27 # stockholm.url = "git+https://cgit.lassul.us/stockholm";
28 # stockholm.url = "path:/home/lass/sync/stockholm";
29 stockholm.inputs.nixpkgs.follows = "nixpkgs";
30 stockholm.inputs.buildbot-nix.follows = "";
31
32 disko.url = "github:nix-community/disko";
33 # disko.url = "path:/home/lass/src/disko/";
34 disko.inputs.nixpkgs.follows = "nixpkgs";
35
36 nixos-hardware.url = "github:nixos/nixos-hardware";
37
38 nether.url = "github:krebs/nether";
39 # nether.url = "git+file:/home/lass/src/nether";
40 nether.inputs.nixpkgs.follows = "nixpkgs";
41 nether.inputs.clan-core.follows = "clan-core";
42 nether.inputs.data-mesher.follows = "";
43
44 spora.url = "github:krebs/spora";
45 # spora.url = "git+file:/home/lass/src/spora";
46 spora.inputs.nixpkgs.follows = "nixpkgs";
47
48 nix-darwin.url = "github:LnL7/nix-darwin";
49 nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
50
51 nix-rosetta-builder.url = "github:cpick/nix-rosetta-builder";
52 nix-rosetta-builder.inputs.nixpkgs.follows = "nixpkgs";
53
54 nixos-facter.url = "github:numtide/nixos-facter-modules";
55
56 treefmt-nix.url = "github:numtide/treefmt-nix";
57 treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
58
59 le_menu.url = "github:lassulus/le_menu";
60 # le_menu.url = "git+file:/home/lass/src/le_menu";
61 le_menu.inputs.nixpkgs.follows = "nixpkgs";
62
63 extra-container.url = "github:erikarvstedt/extra-container";
64 extra-container.inputs.nixpkgs.follows = "nixpkgs";
65
66 llm-agents.url = "github:numtide/llm-agents.nix";
67 llm-agents.inputs.nixpkgs.follows = "nixpkgs";
68
69 hermes-agent.url = "github:nousresearch/hermes-agent";
70 hermes-agent.inputs.nixpkgs.follows = "nixpkgs";
71
72 rogue-talk.url = "github:rogue-talk/rogue-talk";
73 rogue-talk.inputs.nixpkgs.follows = "nixpkgs";
74
75 wrappers.url = "github:lassulus/wrappers";
76 # wrappers.url = "git+file:/home/lass/src/wrappers";
77 wrappers.inputs.nixpkgs.follows = "nixpkgs";
78
79 opencrow.url = "github:pinpox/opencrow";
80 opencrow.inputs.nixpkgs.follows = "nixpkgs";
81
82 nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver";
83 nixos-mailserver.inputs.nixpkgs.follows = "nixpkgs";
84
85 covibe.url = "github:lassulus/covibe";
86 covibe.inputs.nixpkgs.follows = "nixpkgs";
87
88 };
89
90 outputs =
91 inputs@{
92 self,
93 nixpkgs,
94 clan-core,
95 ...
96 }:
97 let
98 clan = clan-core.lib.clan {
99 self = self;
100 specialArgs.self = self;
101 modules = import ./clan_modules { inherit nixpkgs; };
102 vars.settings.secretStore = "password-store";
103 meta.domain = "s";
104 inventory = {
105 meta.name = "superconfig";
106 machines = {
107 ignavia.tags = [
108 "laptop"
109 "focus"
110 ];
111 mors.tags = [
112 "laptop"
113 "focus"
114 ];
115 aergia.tags = [
116 "laptop"
117 "focus"
118 ];
119 barnacle = {
120 machineClass = "darwin";
121 tags = [
122 "laptop"
123 "focus"
124 ];
125 };
126 icarus.tags = [ "laptop" ];
127 prism.tags = [ "server" ];
128 neoprism.tags = [ "server" ];
129 };
130 instances = {
131 tor = {
132 roles.server.tags.all = { };
133 };
134 internet = {
135 roles.default.machines = {
136 prism.settings.host = "prism.lassul.us";
137 prism.settings.port = 45621;
138 neoprism.settings.host = "neoprism.lassul.us";
139 neoprism.settings.port = 45621;
140 };
141 };
142 state-version = {
143 module.name = "importer";
144 roles.default.tags.all = { };
145 roles.default.settings.extraModules = [
146 {
147 clan.core.state-version.enable = true;
148 }
149 ];
150 };
151 yggdrasil = {
152 roles.default.tags.nixos = { };
153 };
154 tor-yggdrasil = {
155 module.name = "tor";
156 roles.client.tags.nixos = { };
157 roles.server.tags.nixos = { };
158 roles.server.settings = {
159 secretHostname = false;
160 portMapping = [
161 {
162 # tcp
163 port = 6443;
164 target.port = 6443;
165 }
166 {
167 # tls
168 port = 6446;
169 target.port = 6443;
170 }
171 ];
172 };
173 };
174 };
175 };
176 machines =
177 nixpkgs.lib.mapAttrs
178 (machineName: _: {
179 imports = [
180 ./machines/${machineName}/physical.nix
181 ];
182 })
183 (
184 nixpkgs.lib.filterAttrs (
185 machineName: _: builtins.pathExists ./machines/${machineName}/physical.nix
186 ) (builtins.readDir ./machines)
187 );
188 };
189 in
190 clan-core.inputs.flake-parts.lib.mkFlake { inherit inputs; } {
191 systems = [
192 "x86_64-linux"
193 "aarch64-linux"
194 "aarch64-darwin"
195 "x86_64-darwin"
196 ];
197 imports = [
198 ./formatter.nix
199 ./5pkgs/flake-module.nix
200 ./keys/flake-module.nix
201 ./skills/flake-module.nix
202 ./games/flake-module.nix
203
204 ./wrapperModules/pi/flake-module.nix
205 ./wrapperModules/claude-code/flake-module.nix
206 ./wrapperModules/noctalia-shell/flake-module.nix
207 {
208 options.flake.wrapperModules = nixpkgs.lib.mkOption {
209 type = nixpkgs.lib.types.lazyAttrsOf nixpkgs.lib.types.raw;
210 default = { };
211 };
212 }
213 ]
214 ++ (
215 # Auto-import all flake-module.nix files from tools subdirectories
216 let
217 toolDirs = builtins.attrNames (
218 nixpkgs.lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./tools)
219 );
220 in
221 map (dir: ./tools + "/${dir}/flake-module.nix") toolDirs
222 );
223 flake.nixosConfigurations = clan.config.nixosConfigurations;
224 flake.clanInternals = clan.config.clanInternals;
225 flake.darwinConfigurations = clan.config.darwinConfigurations;
226 flake.clan = clan.config;
227
228 # Container configurations for use with extra-container
229 # Auto-discovers machines with container.nix
230 flake.containerConfigurations =
231 nixpkgs.lib.mapAttrs
232 (machineName: _: import ./machines/${machineName}/container.nix { inherit self; })
233 (
234 nixpkgs.lib.filterAttrs (
235 machineName: _: builtins.pathExists ./machines/${machineName}/container.nix
236 ) (builtins.readDir ./machines)
237 );
238
239 perSystem =
240 {
241 lib,
242 pkgs,
243 system,
244 ...
245 }:
246 {
247 packages = {
248 default = inputs.le_menu.lib.buildMenu {
249 inherit pkgs;
250 menuConfig = {
251 vim.run = "nix run ${self}#nvim";
252 shell.run = "nix run ${self}#shell";
253 machines.submenu = lib.mapAttrs (name: _machine: {
254 submenu.ssh.submenu = {
255 retiolum.run = "ssh -t ${name}.r";
256 spora.run = "ssh ${name}.s";
257 nether.run = "ssh ${name}.n";
258 tor.run = "torify ssh $(pass show machines/${name}/tor-hostname)";
259 };
260 }) self.nixosConfigurations;
261 debug.run = "env";
262 };
263 };
264 clan-cli = clan-core.packages.${system}.clan-cli;
265 }
266 // lib.mapAttrs' (
267 name: containerConfig:
268 lib.nameValuePair "container-${name}" (
269 inputs.extra-container.lib.buildContainers {
270 inherit system;
271 nixpkgs = inputs.nixpkgs;
272 config = {
273 # Workaround: extra-container's minimal module set doesn't
274 # include nixos-init.nix, but systemd.nix now references
275 # config.system.nixos-init.package for env-generator.
276 # Provide a dummy option until extra-container is updated.
277
278 imports = [
279 (
280 { pkgs, lib, ... }:
281 {
282 options.system.nixos-init.package = lib.mkPackageOption pkgs "nixos-init" { };
283 options.time.timeZone = lib.mkOption {
284 type = lib.types.nullOr lib.types.str;
285 default = null;
286 description = "Dummy option for extra-container compatibility";
287 };
288 options.services.openssh = {
289 enable = lib.mkOption {
290 type = lib.types.bool;
291 default = false;
292 description = "Dummy option for extra-container compatibility";
293 };
294 package = lib.mkPackageOption pkgs "openssh" { };
295 };
296 # systemd.nix sets environment.variables.SYSTEMD_XKB_DIRECTORY,
297 # but the minimal module set omits config/system-environment.nix
298 # which declares the option.
299 options.environment.variables = lib.mkOption {
300 type = lib.types.attrsOf lib.types.anything;
301 default = { };
302 description = "Dummy option for extra-container compatibility";
303 };
304 # systemd.nix reads config.i18n.imperativeLocale, but the
305 # minimal module set omits config/i18n.nix which declares it.
306 options.i18n.imperativeLocale = lib.mkOption {
307 type = lib.types.bool;
308 default = true;
309 description = "Dummy option for extra-container compatibility";
310 };
311 }
312 )
313 ];
314 containers.${name} = containerConfig;
315 };
316 }
317 )
318 ) self.containerConfigurations;
319 devShells.default = pkgs.mkShell {
320 packages = [
321 self.packages.${pkgs.system}.pass
322 (self.legacyPackages.${system}.bin_shim {
323 name = "clan";
324 pkg_name = "clan-cli";
325 })
326 ];
327 };
328 legacyPackages.llm = inputs.llm-agents.packages.${system};
329 checks =
330 let
331 # Check NixOS configurations can be evaluated (without building)
332 nixosChecks = lib.mapAttrs' (
333 name: config:
334 lib.nameValuePair "nixos-${name}" (
335 pkgs.runCommand "eval-${name}" { } ''
336 # Force evaluation of the toplevel path without building
337 echo "Evaluating ${name}: ${builtins.unsafeDiscardStringContext config.config.system.build.toplevel.drvPath}"
338 touch $out
339 ''
340 )
341 ) (lib.filterAttrs (_: config: config.pkgs.system == system) self.nixosConfigurations);
342
343 # Check Darwin configurations can be evaluated (without building)
344 darwinChecks = lib.mapAttrs' (
345 name: config:
346 lib.nameValuePair "darwin-${name}" (
347 pkgs.runCommand "eval-darwin-${name}" { } ''
348 # Force evaluation of the system path without building
349 echo "Evaluating ${name}: ${builtins.unsafeDiscardStringContext config.system.drvPath}"
350 touch $out
351 ''
352 )
353 ) (lib.filterAttrs (_: config: config.pkgs.system == system) self.darwinConfigurations);
354 in
355 nixosChecks // darwinChecks;
356 };
357 flake.lib = import ./lib { inherit (nixpkgs) lib; };
358 };
359}