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