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