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