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