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