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