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