This repository has no description
9.2 kB
269 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 state-version = {
175 module.name = "importer";
176 roles.default.tags.all = { };
177 roles.default.settings.extraModules = [
178 {
179 clan.core.state-version.enable = true;
180 }
181 ];
182 };
183 };
184 };
185 machines =
186 nixpkgs.lib.mapAttrs
187 (machineName: _: {
188 imports = [
189 ./machines/${machineName}/physical.nix
190 ];
191 })
192 (
193 nixpkgs.lib.filterAttrs (
194 machineName: _: builtins.pathExists ./machines/${machineName}/physical.nix
195 ) (builtins.readDir ./machines)
196 );
197 };
198 in
199 flake-parts.lib.mkFlake { inherit inputs; } {
200 systems = [
201 "x86_64-linux"
202 "aarch64-linux"
203 "aarch64-darwin"
204 "x86_64-darwin"
205 ];
206 imports =
207 [
208 ./formatter.nix
209 ./5pkgs/flake-module.nix
210 ./keys/flake-module.nix
211 ]
212 ++ (
213 # Auto-import all flake-module.nix files from tools subdirectories
214 let
215 toolDirs = builtins.attrNames (
216 nixpkgs.lib.filterAttrs (_: type: type == "directory") (builtins.readDir ./tools)
217 );
218 in
219 map (dir: ./tools + "/${dir}/flake-module.nix") toolDirs
220 );
221 flake.nixosConfigurations = clan.nixosConfigurations;
222 flake.clanInternals = clan.clanInternals;
223 flake.darwinConfigurations = clan.darwinConfigurations;
224 flake.clan = clan;
225 perSystem =
226 {
227 lib,
228 pkgs,
229 system,
230 ...
231 }:
232 {
233 packages = {
234 default = inputs.le_menu.lib.buildMenu {
235 inherit pkgs;
236 menuConfig = {
237 vim.run = "nix run ${self}#nvim";
238 shell.run = "nix run ${self}#shell";
239 machines.submenu = lib.mapAttrs (name: _machine: {
240 submenu.ssh.submenu = {
241 retiolum.run = "ssh -t ${name}.r";
242 spora.run = "ssh ${name}.s";
243 nether.run = "ssh ${name}.n";
244 tor.run = "torify ssh $(pass show machines/${name}/tor-hostname)";
245 };
246 }) self.nixosConfigurations;
247 debug.run = "env";
248 };
249 };
250 clan-cli = clan-core.packages.${system}.clan-cli;
251 };
252 devShells.default = pkgs.mkShell {
253 packages = [
254 clan-core.packages.${system}.clan-cli
255 nixpkgs.legacyPackages.${system}.nil
256 nixpkgs.legacyPackages.${system}.nixd
257 ];
258 };
259 };
260 flake.lib = import ./lib { inherit (nixpkgs) lib; };
261 flake.libWithPkgs = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
262 system:
263 import ./lib/pkgs.nix {
264 inherit (nixpkgs) lib;
265 pkgs = nixpkgs.legacyPackages.${system};
266 }
267 );
268 };
269}