Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
373 lines (323 loc) · 11.5 KB
/
Copy pathflake.nix
File metadata and controls
373 lines (323 loc) · 11.5 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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
{
# Based on the "minimal" config from https://github.com/Misterio77/nix-starter-configs
description = "bct's nix config";
nixConfig = {
extra-substituters = [
"https://microvm.cachix.org"
"https://unmojang.cachix.org"
"https://nixos-raspberrypi.cachix.org"
];
extra-trusted-public-keys = [
"microvm.cachix.org-1:oXnBc6hRE3eX5rSYdRyMYXnfzcCxC7yKPTbZXALsqys="
"unmojang.cachix.org-1:OfHnbBNduZ6Smx9oNbLFbYyvOWSoxb2uPcnXPj4EDQY="
"nixos-raspberrypi.cachix.org-1:4iMO9LXa8BqhU+Rpg6LQKiGa2lsNh/j2oiYLNOQ5sPI="
];
};
inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
# bug fixes & new packages
# https://github.com/NixOS/nixpkgs/pull/354032
schromp-netbird.url = "github:schromp/nixpkgs/fix-netbird";
# https://github.com/NixOS/nixpkgs/pull/540077
alvr-grimmory.url = "github:alvr/nixpkgs/grimmory";
# Home manager
home-manager.url = "github:nix-community/home-manager/release-26.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# flake-parts
flake-parts.url = "github:hercules-ci/flake-parts";
# Agenix
agenix.url = "github:ryantm/agenix";
agenix.inputs.nixpkgs.follows = "nixpkgs";
# agenix-rekey
agenix-rekey.url = "github:oddlama/agenix-rekey";
agenix-rekey.inputs.nixpkgs.follows = "nixpkgs";
# deploy-rs
deploy-rs.url = "github:serokell/deploy-rs";
deploy-rs.inputs.nixpkgs.follows = "nixpkgs";
# disko
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
# nixos-hardware
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
# nixos-raspberrypi
# doesn't follow nixpkgs, so that we can take advantage of the cache.
nixos-raspberrypi.url = "github:nvmd/nixos-raspberrypi/main";
# microvm
# doesn't follow nixpkgs, so that we can take advantage of the cache.
microvm.url = "github:astro/microvm.nix";
# nixvirt
nixvirt.url = "https://flakehub.com/f/AshleyYakeley/NixVirt/*.tar.gz";
nixvirt.inputs.nixpkgs.follows = "nixpkgs";
# simple-nixos-mailserver
# https://nixos-mailserver.readthedocs.io/en/latest/index.html
simple-nixos-mailserver.url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-26.05";
# acme-dns-by-proxy
acme-dns-by-proxy.url = "github:bct/acme-dns-by-proxy";
acme-dns-by-proxy.inputs.nixpkgs.follows = "nixpkgs";
# minecraft
nix-minecraft.url = "github:Infinidoge/nix-minecraft";
# packages from flakes
airsonic-refix-jukebox.url = "github:bct/airsonic-refix-jukebox";
airsonic-refix-jukebox.inputs.nixpkgs.follows = "nixpkgs";
grid-select.url = "github:bct/grid-select";
grid-select.inputs.nixpkgs.follows = "nixpkgs";
fjord-launcher.url = "github:unmojang/FjordLauncher";
};
outputs =
{
self,
nixpkgs,
home-manager,
flake-parts,
deploy-rs,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.agenix-rekey.flakeModule
];
systems = [
"aarch64-linux"
"x86_64-linux"
# other systems that I'm not using right now:
# "i686-linux"
# "aarch64-darwin"
# "x86_64-darwin"
];
perSystem =
{
config,
pkgs,
...
}:
{
# Your custom packages
# Acessible through 'nix build', 'nix shell', etc
packages =
let
inherit (self) outputs;
generators = import ./generators {
inherit
inputs
outputs
nixpkgs
;
};
in
import ./pkgs { inherit pkgs; } // generators;
# Devshell for working on configs
# Acessible through 'nix develop'
devShells = import ./shell.nix { inherit config pkgs inputs; };
# agenix-rekey configuration
# see https://flake.parts/options/agenix-rekey
agenix-rekey.nodes =
let
# TODO: what if the hosts have overlapping VM names?
allVms =
self.nixosConfigurations.yuggoth.config.microvm.vms
// self.nixosConfigurations.mi-go.config.microvm.vms;
agenixVms =
nixpkgs.lib.filterAttrs
# only look at VMs with "age" attributes set.
(containerName: { config, ... }: config.config ? age)
allVms;
in
{
inherit (self.nixosConfigurations)
aquilonia
auth
mail
medley
megahost-one
mi-go
ranger
stereo
yuggoth
;
}
// nixpkgs.lib.mapAttrs (containerName: instanceConfig: instanceConfig.config) agenixVms;
};
flake = {
# Your custom packages and modifications, exported as overlays
overlays = import ./overlays { inherit inputs; };
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
nixosConfigurations =
let
inherit (self) outputs;
injectDeps = {
imports = [ ./nixos/common/injected-deps.nix ];
config.diffeq.secretsPath = ./secrets;
};
in
{
# -- desktops
aquilonia = nixpkgs.lib.nixosSystem {
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/aquilonia/configuration.nix
];
};
cimmeria = nixpkgs.lib.nixosSystem {
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/cimmeria/configuration.nix
];
};
stygia = nixpkgs.lib.nixosSystem {
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/stygia/configuration.nix
];
};
# -- LAN hosts
auth = nixpkgs.lib.nixosSystem {
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/vms/auth/configuration.nix
];
};
mail = nixpkgs.lib.nixosSystem {
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/vms/mail/configuration.nix
];
};
mi-go = nixpkgs.lib.nixosSystem {
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/lan/mi-go/configuration.nix
];
};
medley = nixpkgs.lib.nixosSystem {
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/vms/medley/configuration.nix
];
};
ranger = nixpkgs.lib.nixosSystem {
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/vms/ranger/configuration.nix
];
};
# uses our nixpkgs, but adds nixos-raspberrypi's overlays and binary cache.
stereo = inputs.nixos-raspberrypi.lib.nixosSystem {
inherit nixpkgs;
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/lan/stereo/configuration.nix
];
};
yuggoth = nixpkgs.lib.nixosSystem {
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/lan/yuggoth/configuration.nix
];
};
# -- cloud hosts
megahost-one = nixpkgs.lib.nixosSystem {
specialArgs = { inherit self inputs outputs; };
modules = [
injectDeps
./nixos/cloud/megahost-one/configuration.nix
];
};
};
deploy =
let
mkNode =
{
hostname,
arch,
config,
}:
{
inherit hostname;
user = "root";
profiles.system.path = deploy-rs.lib."${arch}".activate.nixos config;
};
in
{
# -- lan hosts --
nodes.auth = mkNode {
hostname = "auth.domus.diffeq.com";
arch = "x86_64-linux";
config = self.nixosConfigurations.auth;
};
nodes.mail = mkNode {
hostname = "mail.domus.diffeq.com";
arch = "x86_64-linux";
config = self.nixosConfigurations.mail;
};
nodes.medley = mkNode {
hostname = "medley.domus.diffeq.com";
arch = "x86_64-linux";
config = self.nixosConfigurations.medley;
};
nodes.mi-go = mkNode {
hostname = "mi-go.domus.diffeq.com";
arch = "x86_64-linux";
config = self.nixosConfigurations.mi-go;
};
nodes.ranger = mkNode {
hostname = "ranger.domus.diffeq.com";
arch = "x86_64-linux";
config = self.nixosConfigurations.ranger;
};
nodes.stereo = mkNode {
hostname = "stereo.domus.diffeq.com";
arch = "aarch64-linux";
config = self.nixosConfigurations.stereo;
};
nodes.yuggoth = mkNode {
hostname = "yuggoth.domus.diffeq.com";
arch = "x86_64-linux";
config = self.nixosConfigurations.yuggoth;
};
# -- cloud hosts --
nodes.megahost-one = mkNode {
hostname = "megahost-one.diffeq.com";
arch = "x86_64-linux";
config = self.nixosConfigurations.megahost-one;
};
};
# Standalone home-manager configuration entrypoint
# Available through 'home-manager --flake .#your-username@your-hostname'
homeConfigurations =
let
inherit (self) outputs;
in
{
"bct@aquilonia" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
extraSpecialArgs = { inherit inputs outputs; };
modules = [ ./home-manager/aquilonia ];
};
"bct@cimmeria" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
extraSpecialArgs = { inherit inputs outputs; };
modules = [ ./home-manager/cimmeria ];
};
"bct@stygia" = home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
extraSpecialArgs = { inherit inputs outputs; };
modules = [ ./home-manager/stygia ];
};
};
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
};
};
}