-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
306 lines (266 loc) · 8.73 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
# naersk and flake utils are not used by this flake directly, but needed
# for the follows in all the other ones.
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
# DO NOT remame this to utils
flake-utils.url = "github:numtide/flake-utils";
microvm = {
url = "github:astro/microvm.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
private-flake-overlays = {
url = "github:marenz2569/private-flake-overlays";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware.url = "github:NixOS/nixos-hardware";
## TLMS stuff below
trekkie = {
url = "github:tlm-solutions/trekkie";
inputs = {
nixpkgs.follows = "nixpkgs";
naersk.follows = "naersk";
tlms-rs.follows = "tlms-rs";
utils.follows = "flake-utils";
};
};
datacare = {
url = "github:tlm-solutions/datacare";
};
kindergarten = {
url = "github:tlm-solutions/kindergarten";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
telegram-decoder = {
url = "github:tlm-solutions/telegram-decoder";
inputs = {
nixpkgs.follows = "nixpkgs";
naersk.follows = "naersk";
utils.follows = "flake-utils";
};
};
r09-receiver = {
url = "github:tlm-solutions/r09-receiver";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
data-accumulator = {
url = "github:tlm-solutions/data-accumulator";
inputs.nixpkgs.follows = "nixpkgs";
inputs.naersk.follows = "naersk";
inputs.utils.follows = "flake-utils";
};
lizard = {
url = "github:tlm-solutions/lizard";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
bureaucrat = {
url = "github:tlm-solutions/bureaucrat";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
funnel = {
url = "github:tlm-solutions/funnel";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
tlms-rs = {
url = "github:tlm-solutions/tlms.rs";
inputs.nixpkgs.follows = "nixpkgs";
};
chemo = {
url = "github:tlm-solutions/chemo";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
borzoi = {
url = "github:tlm-solutions/borzoi";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{ self
, private-flake-overlays
, borzoi
, data-accumulator
, datacare
, funnel
, r09-receiver
, kindergarten
, microvm
, nixpkgs
, sops-nix
, lizard
, bureaucrat
, telegram-decoder
, trekkie
, chemo
, nixos-hardware
, ...
}:
let
pkgs = nixpkgs.legacyPackages."x86_64-linux";
lib = pkgs.lib;
overlayFlake = private-flake-overlays.lib.overlayFlake;
registry = import ./registry;
data-hoarder-modules = [
./modules/data-hoarder
./modules/TLMS
data-accumulator.nixosModules.default
datacare.nixosModules.default
funnel.nixosModules.default
sops-nix.nixosModules.sops
lizard.nixosModules.default
bureaucrat.nixosModules.default
trekkie.nixosModules.default
chemo.nixosModules.default
{
nixpkgs.overlays = [
datacare.overlays.default
kindergarten.overlays.default
trekkie.overlays.default
lizard.overlays.default
bureaucrat.overlays.default
funnel.overlays.default
data-accumulator.overlays.default
chemo.overlays.default
];
}
];
stop-box-modules = [
./modules/TLMS
telegram-decoder.nixosModules.default
r09-receiver.nixosModules.default
{
nixpkgs.overlays = [
telegram-decoder.overlays.default
r09-receiver.overlays.default
];
}
];
# function that generates a system with the given number
generate_system = (id:
let
myRegistry = registry.traffic-stop-box."${toString id}";
in
{
"${myRegistry.hostName}" = {
system = myRegistry.arch;
specialArgs = { inherit self inputs; registry = myRegistry; };
modules =
[
# box-specific config
./hosts/traffic-stop-box/${toString id}
# default modules
sops-nix.nixosModules.sops
./modules/traffic-stop-box
./modules/TLMS
{
deployment-TLMS.monitoring.enable = myRegistry.monitoring;
}
] ++ stop-box-modules;
};
}
);
# list of traffic-stop-box-$id that will be built
stop_box_ids = [ 0 1 4 8 9 ];
# attribute set of all traffic stop boxes
r09_receivers = nixpkgs.lib.foldl (x: id: nixpkgs.lib.mergeAttrs x (generate_system id)) { } stop_box_ids;
unevaluatedNixosConfigurations = r09_receivers // {
data-hoarder = {
system = "x86_64-linux";
specialArgs = { inherit inputs self; registry = registry.data-hoarder; };
modules = [
microvm.nixosModules.microvm
./hosts/data-hoarder
] ++ data-hoarder-modules;
};
staging-data-hoarder = {
system = "x86_64-linux";
specialArgs = { inherit inputs self; registry = registry.staging-data-hoarder; };
modules = [
./hosts/staging-data-hoarder
microvm.nixosModules.microvm
] ++ data-hoarder-modules;
};
notice-me-senpai = {
system = "x86_64-linux";
specialArgs = { inherit inputs self; registry = registry.notice-me-senpai; };
modules = [
sops-nix.nixosModules.sops
microvm.nixosModules.microvm
./modules/TLMS
./hosts/notice-me-senpai
];
};
tram-borzoi = {
system = "x86_64-linux";
specialArgs = { inherit inputs self; registry = registry.tram-borzoi; };
modules = [
sops-nix.nixosModules.sops
microvm.nixosModules.microvm
borzoi.nixosModules.default
{ nixpkgs.overlays = [ borzoi.overlays.default ]; }
./modules/TLMS
./hosts/tram-borzoi
];
};
tetra-zw = {
system = "x86_64-linux";
specialArgs = { inherit inputs self; registry = registry.tetra-zw; };
modules = [
sops-nix.nixosModules.sops
nixos-hardware.nixosModules.lenovo-thinkpad-t14-amd-gen1
./modules/TLMS
./hosts/tetra-zw
];
};
uranus = {
system = "x86_64-linux";
specialArgs = {
inherit inputs self;
registry = registry.uranus;
bind-ip = registry.uranus.wgAddr4;
};
modules = [
sops-nix.nixosModules.sops
microvm.nixosModules.microvm
./modules/TLMS
./hosts/uranus
];
};
};
in
# overlays this private flake when in impure mode
overlayFlake "git+ssh://git@github.com/tlm-solutions/nix-config-private.git" {
inherit unevaluatedNixosConfigurations;
packages."aarch64-linux".box8 = self.nixosConfigurations.traffic-stop-box-8.config.system.build.sdImage;
packages."aarch64-linux".box9 = self.nixosConfigurations.traffic-stop-box-9.config.system.build.sdImage;
packages."x86_64-linux" = {
staging-microvm = self.nixosConfigurations.staging-data-hoarder.config.microvm.declaredRunner;
data-hoarder-microvm = self.nixosConfigurations.data-hoarder.config.microvm.declaredRunner;
};
# these are in the app declaration as nix before 2.19 tries to find attrPaths in packages first.
# here we evaluate over all nixos configurations making this extremely slow
apps."x86_64-linux" = (import ./pkgs/deployment.nix { inherit self pkgs lib; });
nixosConfigurations = lib.attrsets.mapAttrs (name: value: (nixpkgs.lib.nixosSystem value)) unevaluatedNixosConfigurations;
hydraJobs =
let
get-toplevel = (host: nixSystem: nixSystem.config.microvm.declaredRunner or nixSystem.config.system.build.toplevel);
in
nixpkgs.lib.mapAttrs get-toplevel self.nixosConfigurations;
};
}