-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
348 lines (298 loc) · 10.6 KB
/
Copy pathflake.nix
File metadata and controls
348 lines (298 loc) · 10.6 KB
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
# NOTE: we don't explicitly depend on home-manager, but there's a narHash
# mismatch when we let agenix define it, so we include it here so we can
# bump and control the version.
home-manager = {
url = "github:nix-community/home-manager/release-26.05";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
# Seabird core
seabird-core-release = {
url = "github:seabird-chat/seabird-core/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-core-dev = {
url = "github:seabird-chat/seabird-core";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
# Seabird backends
seabird-discord-backend-release = {
url = "github:seabird-chat/seabird-discord-backend/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-discord-backend-dev = {
url = "github:seabird-chat/seabird-discord-backend";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-irc-backend-release = {
url = "github:seabird-chat/seabird-irc-backend/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-irc-backend-dev = {
url = "github:seabird-chat/seabird-irc-backend";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
# Seabird plugins
seabird-datadog-plugin-release = {
url = "github:seabird-chat/seabird-datadog-plugin/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-datadog-plugin-dev = {
url = "github:seabird-chat/seabird-datadog-plugin";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-adventofcode-plugin-release = {
url = "github:seabird-chat/seabird-adventofcode-plugin/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-adventofcode-plugin-dev = {
url = "github:seabird-chat/seabird-adventofcode-plugin";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-github-plugin-release = {
url = "github:seabird-chat/seabird-github-plugin/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-github-plugin-dev = {
url = "github:seabird-chat/seabird-github-plugin";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-plugin-bundle-release = {
url = "github:seabird-chat/seabird-plugin-bundle/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-plugin-bundle-dev = {
url = "github:seabird-chat/seabird-plugin-bundle";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-proxy-plugin-release = {
url = "github:seabird-chat/seabird-proxy-plugin/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-proxy-plugin-dev = {
url = "github:seabird-chat/seabird-proxy-plugin";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-nwwsio-plugin-release = {
url = "github:seabird-chat/seabird-nwwsio-plugin/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-nwwsio-plugin-dev = {
url = "github:seabird-chat/seabird-nwwsio-plugin";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-stock-plugin-release = {
url = "github:seabird-chat/seabird-stock-plugin/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-stock-plugin-dev = {
url = "github:seabird-chat/seabird-stock-plugin";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-url-plugin-release = {
url = "github:seabird-chat/seabird-url-plugin/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-url-plugin-dev = {
url = "github:seabird-chat/seabird-url-plugin";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
# Other
seabird-webhook-receiver-release = {
url = "github:seabird-chat/seabird-webhook-receiver/release";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
seabird-webhook-receiver-dev = {
url = "github:seabird-chat/seabird-webhook-receiver";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
};
outputs =
inputs@{
self,
nixpkgs,
flake-parts,
...
}:
let
myLib = import ./lib.nix inputs;
in
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-linux"
];
flake = {
overlays = import ./overlays.nix inputs;
nixosModules.default = import ./nixos/modules;
nixosConfigurations = {
"eiko" = myLib.mkNixosSystem {
modules = [
./nixos/hosts/eiko
./nixos/users/belak
./nixos/users/ghavil
];
};
# The image a new guest is provisioned from, before it has an SSH
# host key and therefore before agenix can decrypt anything. Not a
# host: it is replaced by the real configuration on first deploy.
"bootstrap" = myLib.mkNixosSystem {
modules = [
./nixos/hosts/bootstrap
];
};
# VM guests on eiko. Both carry the belak user, so its agenix password
# has to be readable by them before a deploy will activate.
"kupo" = myLib.mkNixosSystem {
modules = [
./nixos/hosts/kupo
./nixos/users/belak
./nixos/users/ghavil
];
};
"stiltzkin" = myLib.mkNixosSystem {
modules = [
./nixos/hosts/stiltzkin
./nixos/users/belak
./nixos/users/ghavil
];
};
};
deploy.nodes = {
# eiko sits on the homelab network rather than behind the seabird
# edge, so it is reached by its internal name.
"eiko" = {
hostname = "eiko.infra.seabird.chat";
profiles.system = myLib.mkNixosDeploy self.nixosConfigurations."eiko";
};
# Reached over SSH like any other host once it has a lease. The host
# owns the runner, so a change to kernel or initrd needs eiko
# deployed as well.
"kupo" = {
hostname = "kupo.infra.seabird.chat";
profiles.system = myLib.mkNixosDeploy self.nixosConfigurations."kupo";
};
"stiltzkin" = {
hostname = "stiltzkin.infra.seabird.chat";
profiles.system = myLib.mkNixosDeploy self.nixosConfigurations."stiltzkin";
};
};
};
perSystem =
{
pkgs,
system,
lib,
...
}:
{
_module.args.pkgs = import nixpkgs {
inherit system;
overlays = builtins.attrValues self.overlays;
config = { };
};
formatter = pkgs.treefmt.withConfig {
runtimeInputs = [ pkgs.nixfmt ];
settings = {
# Log level for files treefmt won't format
on-unmatched = "info";
# Configure nixfmt for .nix files
formatter.nixfmt = {
command = "nixfmt";
includes = [ "*.nix" ];
};
};
};
packages =
let
all-prod = pkgs.linkFarmFromDrvs "seabird-all-prod" (lib.attrValues pkgs.seabird);
all-staging = pkgs.linkFarmFromDrvs "seabird-all-staging" (lib.attrValues pkgs.seabird-staging);
in
pkgs.seabird
# Disk image for first provisioning of a VM guest. One image serves
# every guest: the reservation is per MAC, so it lands on the right
# address, and the first deploy gives it its real identity. After a
# guest boots, its disk is state and deploy-rs owns updates; writing
# a fresh image over it would roll the guest back to birth.
// lib.optionalAttrs (system == "x86_64-linux") {
bootstrap-image = self.nixosConfigurations."bootstrap".config.system.build.diskoImages;
}
// {
# Per-environment aggregates, so a host can pin the set it actually
# runs rather than both.
inherit all-prod all-staging;
# Everything, for the CI pipeline that pushes closures to the
# attic cache in one build.
all = pkgs.linkFarmFromDrvs "seabird-all" [
all-prod
all-staging
];
};
devShells.default = pkgs.mkShell {
packages = [
pkgs.agenix
pkgs.deploy-rs
];
};
# Pinned toolchain for the attic push pipeline (see .woodpecker.yml).
devShells.ci = pkgs.mkShell {
packages = [
pkgs.attic-client
];
};
# Toolchain for the deploy-rs CD pipeline (see .woodpecker.yml).
# openssh provides ssh-agent/ssh-add for the deploy key.
devShells.deploy = pkgs.mkShell {
packages = [
pkgs.deploy-rs
pkgs.openssh
];
};
};
};
}