This repository has no description
10 kB
291 lines
1{
2 description = "lassulus superconfig";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6 # nixpkgs.url = "path:/home/lass/tmp/nixpkgs-disk-debug";
7 # nixpkgs.url = "git+file:/home/lass/src/nixpkgs";
8 # nixpkgs.url = "git+file:/Users/lassulus/src/nixpkgs";
9
10 flake-parts.url = "github:hercules-ci/flake-parts";
11
12 nix-index-database.url = "github:nix-community/nix-index-database";
13 nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
14
15 nixvim.url = "github:nix-community/nixvim";
16 nixvim.inputs.nixpkgs.follows = "nixpkgs";
17
18 clan-core.url = "git+https://git.clan.lol/clan/clan-core";
19 # clan-core.url = "path:/Users/lassulus/src/clan/clan-core";
20 # clan-core.url = "git+file:/home/lass/src/clan/clan-core";
21 clan-core.inputs.nixpkgs.follows = "nixpkgs";
22 clan-core.inputs.flake-parts.follows = "flake-parts";
23 clan-core.inputs.disko.follows = "disko";
24
25 stockholm.url = "git+https://github.com/krebs/stockholm?submodules=1";
26 # stockholm.url = "git+https://cgit.lassul.us/stockholm";
27 # stockholm.url = "path:/home/lass/sync/stockholm";
28 stockholm.inputs.nixpkgs.follows = "nixpkgs";
29 stockholm.inputs.buildbot-nix.follows = "";
30
31 disko.url = "github:nix-community/disko";
32 # disko.url = "path:/home/lass/src/disko/";
33 disko.inputs.nixpkgs.follows = "nixpkgs";
34
35 nixos-hardware.url = "github:nixos/nixos-hardware";
36
37 nether.url = "github:krebs/nether";
38 # nether.url = "git+file:/home/lass/src/nether";
39 nether.inputs.nixpkgs.follows = "nixpkgs";
40 nether.inputs.clan-core.follows = "clan-core";
41 nether.inputs.data-mesher.follows = "";
42
43 spora.url = "github:krebs/spora";
44 # spora.url = "git+file:/home/lass/src/spora";
45 spora.inputs.nixpkgs.follows = "nixpkgs";
46
47 nix-darwin.url = "github:LnL7/nix-darwin";
48 nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
49
50 nix-rosetta-builder.url = "github:cpick/nix-rosetta-builder";
51 nix-rosetta-builder.inputs.nixpkgs.follows = "nixpkgs";
52
53 nixos-facter.url = "github:numtide/nixos-facter-modules";
54
55 treefmt-nix.url = "github:numtide/treefmt-nix";
56 treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
57
58 le_menu.url = "github:lassulus/le_menu";
59 # le_menu.url = "git+file:/home/lass/src/le_menu";
60 le_menu.inputs.nixpkgs.follows = "nixpkgs";
61 };
62
63 outputs =
64 inputs@{
65 self,
66 flake-parts,
67 nixpkgs,
68 clan-core,
69 ...
70 }:
71 let
72 clan = clan-core.lib.buildClan {
73 self = self;
74 specialArgs.self = self;
75 exportsModule =
76 { lib, ... }:
77 {
78 options.networking = {
79 priority = lib.mkOption {
80 type = lib.types.int;
81 default = 1000;
82 description = ''
83 priority with which this network should be tried.
84 higher priority means it gets used earlier in the chain
85 '';
86 };
87 technology = lib.mkOption {
88 # addding more technologies requires code in the clan-cli to handle that technology
89 # at least for userspace networking
90 # maybe we can do a fallback mode for vpns where we don't need userspace networking?
91 type = lib.types.enum [
92 "direct"
93 "tor"
94 ];
95 description = ''
96 the technology this network uses to connect to the target
97 This is used for userspace networking with socks proxies.
98 '';
99 };
100 # should we call this machines? hosts?
101 peers = lib.mkOption {
102 # <name>
103 type = lib.types.attrsOf (
104 lib.types.submodule (
105 { name, ... }:
106 {
107 options = {
108 name = lib.mkOption {
109 type = lib.types.str;
110 default = name;
111 };
112 SSHOptions = lib.mkOption {
113 type = lib.types.listOf lib.types.str;
114 default = [ ];
115 };
116 host = lib.mkOption {
117 description = '''';
118 type = lib.types.attrTag {
119 plain = lib.mkOption {
120 type = lib.types.str;
121 description = ''
122 a plain value, which can be read directly from the config
123 '';
124 };
125 var = lib.mkOption {
126 type = lib.types.submodule {
127 options = {
128 machine = lib.mkOption {
129 type = lib.types.str;
130 example = "jon";
131 };
132 generator = lib.mkOption {
133 type = lib.types.str;
134 example = "tor-ssh";
135 };
136 file = lib.mkOption {
137 type = lib.types.str;
138 example = "hostname";
139 };
140 };
141 };
142 };
143 };
144 };
145 };
146 }
147 )
148 );
149 };
150 };
151 };
152 modules = import ./clan_modules { inherit nixpkgs; };
153 inventory = {
154 meta.name = "superconfig";
155 machines = {
156 ignavia.tags = [
157 "laptop"
158 "focus"
159 ];
160 mors.tags = [
161 "laptop"
162 "focus"
163 ];
164 aergia.tags = [
165 "laptop"
166 "focus"
167 ];
168 barnacle = {
169 machineClass = "darwin";
170 tags = [
171 "laptop"
172 "focus"
173 ];
174 };
175 icarus.tags = [ "laptop" ];
176 prism.tags = [ "server" ];
177 neoprism.tags = [ "server" ];
178 };
179 instances = {
180 tor = {
181 module.name = "tor";
182 module.input = "self";
183 roles.default.tags.all = { };
184 };
185 internet = {
186 module.name = "internet";
187 module.input = "self";
188 roles.default.machines = {
189 prism.settings.host = "prism.lassul.us";
190 neoprism.settings.host = "neoprism.lassul.us";
191 };
192 };
193 state-version = {
194 module.name = "importer";
195 roles.default.tags.all = { };
196 roles.default.settings.extraModules = [
197 {
198 clan.core.state-version.enable = true;
199 }
200 ];
201 };
202 };
203 };
204 machines =
205 nixpkgs.lib.mapAttrs
206 (machineName: _: {
207 imports = [
208 ./machines/${machineName}/physical.nix
209 ];
210 })
211 (
212 nixpkgs.lib.filterAttrs (
213 machineName: _: builtins.pathExists ./machines/${machineName}/physical.nix
214 ) (builtins.readDir ./machines)
215 );
216 };
217 in
218 flake-parts.lib.mkFlake { inherit inputs; } {
219 systems = [
220 "x86_64-linux"
221 "aarch64-linux"
222 "aarch64-darwin"
223 "x86_64-darwin"
224 ];
225 imports =
226 [
227 ./formatter.nix
228 ./5pkgs/flake-module.nix
229 ./keys/flake-module.nix
230 ]
231 ++ (
232 # Auto-import all flake-module.nix files from tools subdirectories
233 let
234 toolDirs = builtins.attrNames (
235 nixpkgs.lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./tools)
236 );
237 in
238 map (dir: ./tools + "/${dir}/flake-module.nix") toolDirs
239 );
240 flake.nixosConfigurations = clan.nixosConfigurations;
241 flake.clanInternals = clan.clanInternals;
242 flake.darwinConfigurations = clan.darwinConfigurations;
243 flake.clan = clan;
244 perSystem =
245 {
246 lib,
247 pkgs,
248 system,
249 ...
250 }:
251 {
252 packages = {
253 default = inputs.le_menu.lib.buildMenu {
254 inherit pkgs;
255 menuConfig = {
256 vim.run = "nix run ${self}#nvim";
257 shell.run = "nix run ${self}#shell";
258 machines.submenu = lib.mapAttrs (name: _machine: {
259 submenu.ssh.submenu = {
260 retiolum.run = "ssh -t ${name}.r";
261 spora.run = "ssh ${name}.s";
262 nether.run = "ssh ${name}.n";
263 tor.run = "torify ssh $(pass show machines/${name}/tor-hostname)";
264 };
265 }) self.nixosConfigurations;
266 debug.run = "env";
267 };
268 };
269 clan-cli = clan-core.packages.${system}.clan-cli;
270 };
271 devShells.default = pkgs.mkShell {
272 packages = [
273 nixpkgs.legacyPackages.${system}.nil
274 nixpkgs.legacyPackages.${system}.nixd
275 (self.legacyPackages.${system}.bin_shim {
276 name = "clan";
277 pkg_name = "clan-cli";
278 })
279 ];
280 };
281 };
282 flake.lib = import ./lib { inherit (nixpkgs) lib; };
283 flake.libWithPkgs = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
284 system:
285 import ./lib/pkgs.nix {
286 inherit (nixpkgs) lib;
287 pkgs = nixpkgs.legacyPackages.${system};
288 }
289 );
290 };
291}