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