This repository has no description
11 kB
312 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:Lassulus/opencrow/tool_n_stop";
74 opencrow.inputs.nixpkgs.follows = "nixpkgs";
75 };
76
77 outputs =
78 inputs@{
79 self,
80 nixpkgs,
81 clan-core,
82 ...
83 }:
84 let
85 clan = clan-core.lib.clan {
86 self = self;
87 specialArgs.self = self;
88 modules = import ./clan_modules { inherit nixpkgs; };
89 vars.settings.secretStore = "password-store";
90 meta.domain = "s";
91 inventory = {
92 meta.name = "superconfig";
93 machines = {
94 ignavia.tags = [
95 "laptop"
96 "focus"
97 ];
98 mors.tags = [
99 "laptop"
100 "focus"
101 ];
102 aergia.tags = [
103 "laptop"
104 "focus"
105 ];
106 barnacle = {
107 machineClass = "darwin";
108 tags = [
109 "laptop"
110 "focus"
111 ];
112 };
113 icarus.tags = [ "laptop" ];
114 prism.tags = [ "server" ];
115 neoprism.tags = [ "server" ];
116 };
117 instances = {
118 tor = {
119 roles.server.tags.all = { };
120 };
121 internet = {
122 roles.default.machines = {
123 prism.settings.host = "prism.lassul.us";
124 prism.settings.port = 45621;
125 neoprism.settings.host = "neoprism.lassul.us";
126 neoprism.settings.port = 45621;
127 };
128 };
129 state-version = {
130 module.name = "importer";
131 roles.default.tags.all = { };
132 roles.default.settings.extraModules = [
133 {
134 clan.core.state-version.enable = true;
135 }
136 ];
137 };
138 yggdrasil = {
139 roles.default.tags.nixos = { };
140 };
141 tor-yggdrasil = {
142 module.name = "tor";
143 roles.client.tags.nixos = { };
144 roles.server.tags.nixos = { };
145 roles.server.settings = {
146 secretHostname = false;
147 portMapping = [
148 {
149 # tcp
150 port = 6443;
151 target.port = 6443;
152 }
153 {
154 # tls
155 port = 6446;
156 target.port = 6443;
157 }
158 ];
159 };
160 };
161 };
162 };
163 machines =
164 nixpkgs.lib.mapAttrs
165 (machineName: _: {
166 imports = [
167 ./machines/${machineName}/physical.nix
168 ];
169 })
170 (
171 nixpkgs.lib.filterAttrs (
172 machineName: _: builtins.pathExists ./machines/${machineName}/physical.nix
173 ) (builtins.readDir ./machines)
174 );
175 };
176 in
177 clan-core.inputs.flake-parts.lib.mkFlake { inherit inputs; } {
178 systems = [
179 "x86_64-linux"
180 "aarch64-linux"
181 "aarch64-darwin"
182 "x86_64-darwin"
183 ];
184 imports = [
185 ./formatter.nix
186 ./5pkgs/flake-module.nix
187 ./keys/flake-module.nix
188 ./skills/flake-module.nix
189 ./games/flake-module.nix
190
191 ./wrapperModules/pi/flake-module.nix
192 ]
193 ++ (
194 # Auto-import all flake-module.nix files from tools subdirectories
195 let
196 toolDirs = builtins.attrNames (
197 nixpkgs.lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./tools)
198 );
199 in
200 map (dir: ./tools + "/${dir}/flake-module.nix") toolDirs
201 );
202 flake.nixosConfigurations = clan.config.nixosConfigurations;
203 flake.clanInternals = clan.config.clanInternals;
204 flake.darwinConfigurations = clan.config.darwinConfigurations;
205 flake.clan = clan.config;
206
207 # Container configurations for use with extra-container
208 # Auto-discovers machines with container.nix
209 flake.containerConfigurations =
210 nixpkgs.lib.mapAttrs
211 (machineName: _: import ./machines/${machineName}/container.nix { inherit self; })
212 (
213 nixpkgs.lib.filterAttrs (
214 machineName: _: builtins.pathExists ./machines/${machineName}/container.nix
215 ) (builtins.readDir ./machines)
216 );
217
218 perSystem =
219 {
220 lib,
221 pkgs,
222 system,
223 ...
224 }:
225 {
226 packages = {
227 default = inputs.le_menu.lib.buildMenu {
228 inherit pkgs;
229 menuConfig = {
230 vim.run = "nix run ${self}#nvim";
231 shell.run = "nix run ${self}#shell";
232 machines.submenu = lib.mapAttrs (name: _machine: {
233 submenu.ssh.submenu = {
234 retiolum.run = "ssh -t ${name}.r";
235 spora.run = "ssh ${name}.s";
236 nether.run = "ssh ${name}.n";
237 tor.run = "torify ssh $(pass show machines/${name}/tor-hostname)";
238 };
239 }) self.nixosConfigurations;
240 debug.run = "env";
241 };
242 };
243 clan-cli = clan-core.packages.${system}.clan-cli;
244 }
245 // lib.mapAttrs' (
246 name: containerConfig:
247 lib.nameValuePair "container-${name}" (
248 inputs.extra-container.lib.buildContainers {
249 inherit system;
250 nixpkgs = inputs.nixpkgs;
251 config = {
252 # Workaround: extra-container's minimal module set doesn't
253 # include nixos-init.nix, but systemd.nix now references
254 # config.system.nixos-init.package for env-generator.
255 # Provide a dummy option until extra-container is updated.
256
257 imports = [
258 (
259 { pkgs, lib, ... }:
260 {
261 options.system.nixos-init.package = lib.mkPackageOption pkgs "nixos-init" { };
262 }
263 )
264 ];
265 containers.${name} = containerConfig;
266 };
267 }
268 )
269 ) self.containerConfigurations;
270 devShells.default = pkgs.mkShell {
271 packages = [
272 nixpkgs.legacyPackages.${system}.nil
273 nixpkgs.legacyPackages.${system}.nixd
274 self.packages.${pkgs.system}.pass
275 (self.legacyPackages.${system}.bin_shim {
276 name = "clan";
277 pkg_name = "clan-cli";
278 })
279 ];
280 };
281 legacyPackages.llm = inputs.llm-agents.packages.${system};
282 checks =
283 let
284 # Check NixOS configurations can be evaluated (without building)
285 nixosChecks = lib.mapAttrs' (
286 name: config:
287 lib.nameValuePair "nixos-${name}" (
288 pkgs.runCommand "eval-${name}" { } ''
289 # Force evaluation of the toplevel path without building
290 echo "Evaluating ${name}: ${builtins.unsafeDiscardStringContext config.config.system.build.toplevel.drvPath}"
291 touch $out
292 ''
293 )
294 ) (lib.filterAttrs (_: config: config.pkgs.system == system) self.nixosConfigurations);
295
296 # Check Darwin configurations can be evaluated (without building)
297 darwinChecks = lib.mapAttrs' (
298 name: config:
299 lib.nameValuePair "darwin-${name}" (
300 pkgs.runCommand "eval-darwin-${name}" { } ''
301 # Force evaluation of the system path without building
302 echo "Evaluating ${name}: ${builtins.unsafeDiscardStringContext config.system.drvPath}"
303 touch $out
304 ''
305 )
306 ) (lib.filterAttrs (_: config: config.pkgs.system == system) self.darwinConfigurations);
307 in
308 nixosChecks // darwinChecks;
309 };
310 flake.lib = import ./lib { inherit (nixpkgs) lib; };
311 };
312}