This repository has no description
7.9 kB
228 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 = "root@prism.lassul.us:45621";
106 neoprism.settings.host = "root@neoprism.lassul.us:45621";
107 };
108 };
109 state-version = {
110 module.name = "importer";
111 roles.default.tags.all = { };
112 roles.default.settings.extraModules = [
113 {
114 clan.core.state-version.enable = true;
115 }
116 ];
117 };
118 };
119 };
120 machines =
121 nixpkgs.lib.mapAttrs
122 (machineName: _: {
123 imports = [
124 ./machines/${machineName}/physical.nix
125 ];
126 })
127 (
128 nixpkgs.lib.filterAttrs (
129 machineName: _: builtins.pathExists ./machines/${machineName}/physical.nix
130 ) (builtins.readDir ./machines)
131 );
132 };
133 in
134 clan-core.inputs.flake-parts.lib.mkFlake { inherit inputs; } {
135 systems = [
136 "x86_64-linux"
137 "aarch64-linux"
138 "aarch64-darwin"
139 "x86_64-darwin"
140 ];
141 imports = [
142 ./formatter.nix
143 ./5pkgs/flake-module.nix
144 ./keys/flake-module.nix
145 ./wrapperModules/flake-module.nix
146 ]
147 ++ (
148 # Auto-import all flake-module.nix files from tools subdirectories
149 let
150 toolDirs = builtins.attrNames (
151 nixpkgs.lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./tools)
152 );
153 in
154 map (dir: ./tools + "/${dir}/flake-module.nix") toolDirs
155 );
156 flake.nixosConfigurations = clan.nixosConfigurations;
157 flake.clanInternals = clan.clanInternals;
158 flake.darwinConfigurations = clan.darwinConfigurations;
159 flake.clan = clan;
160 perSystem =
161 {
162 lib,
163 pkgs,
164 system,
165 ...
166 }:
167 {
168 packages = {
169 default = inputs.le_menu.lib.buildMenu {
170 inherit pkgs;
171 menuConfig = {
172 vim.run = "nix run ${self}#nvim";
173 shell.run = "nix run ${self}#shell";
174 machines.submenu = lib.mapAttrs (name: _machine: {
175 submenu.ssh.submenu = {
176 retiolum.run = "ssh -t ${name}.r";
177 spora.run = "ssh ${name}.s";
178 nether.run = "ssh ${name}.n";
179 tor.run = "torify ssh $(pass show machines/${name}/tor-hostname)";
180 };
181 }) self.nixosConfigurations;
182 debug.run = "env";
183 };
184 };
185 clan-cli = clan-core.packages.${system}.clan-cli;
186 };
187 devShells.default = pkgs.mkShell {
188 packages = [
189 nixpkgs.legacyPackages.${system}.nil
190 nixpkgs.legacyPackages.${system}.nixd
191 self.packages.${pkgs.system}.pass
192 (self.legacyPackages.${system}.bin_shim {
193 name = "clan";
194 pkg_name = "clan-cli";
195 })
196 ];
197 };
198 checks =
199 let
200 # Check NixOS configurations can be evaluated (without building)
201 nixosChecks = lib.mapAttrs' (
202 name: config:
203 lib.nameValuePair "nixos-${name}" (
204 pkgs.runCommand "eval-${name}" { } ''
205 # Force evaluation of the toplevel path without building
206 echo "Evaluating ${name}: ${builtins.unsafeDiscardStringContext config.config.system.build.toplevel.drvPath}"
207 touch $out
208 ''
209 )
210 ) (lib.filterAttrs (_: config: config.pkgs.system == system) self.nixosConfigurations);
211
212 # Check Darwin configurations can be evaluated (without building)
213 darwinChecks = lib.mapAttrs' (
214 name: config:
215 lib.nameValuePair "darwin-${name}" (
216 pkgs.runCommand "eval-darwin-${name}" { } ''
217 # Force evaluation of the system path without building
218 echo "Evaluating ${name}: ${builtins.unsafeDiscardStringContext config.system.drvPath}"
219 touch $out
220 ''
221 )
222 ) (lib.filterAttrs (_: config: config.pkgs.system == system) self.darwinConfigurations);
223 in
224 nixosChecks // darwinChecks;
225 };
226 flake.lib = import ./lib { inherit (nixpkgs) lib; };
227 };
228}