forked from badele/nix-homelab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
333 lines (301 loc) · 11.5 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
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
{
# See
# Flake => https://nixos.wiki/wiki/Flakes
description = "Nixos homelab configuration with flakes";
inputs = {
# Nixpkgs
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# nixpkgs.url = "path:/home/badele/ghq/github.com/badele/fork-nixpkgs";
# nixpkgs.url = "github:badele/fork-nixpkgs/unstable-fix-smokeping-symbolic-links";
# You can access packages and modules from different nixpkgs revs
# at the same time. Here's an working example:
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
# Home manager
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
# hardware.url = "git+file:///home/badele/ghq/github.com/badele/fork-nixos-hardware";
# hardware.url = "github:badele/fork-nixos-hardware/xps-15-9530";
hardware.url = "github:NixOS/nixos-hardware/master";
impermanence = { url = "github:nix-community/impermanence"; };
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Color scheme
stylix.url = "github:danth/stylix";
};
outputs =
{ self
, nixpkgs
, home-manager
, sops-nix
, hardware
# , nix-pre-commit
, stylix
, nur
, ...
}@inputs:
let
inherit (self) outputs;
forAllSystems = nixpkgs.lib.genAttrs [
"aarch64-linux"
# "i686-linux"
"x86_64-linux"
# "aarch64-darwin"
# "x86_64-darwin"
];
in
rec {
# Your custom packages
# Acessible through 'nix build', 'nix shell', etc
packages = forAllSystems (system:
let pkgs = import nixpkgs { inherit system; };
in import ./nix/pkgs { inherit pkgs; });
# Devshell for bootstrapping
# Acessible through 'nix develop' or 'nix-shell' (legacy)
devShells = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in import ./shell.nix { inherit pkgs system; });
# Your custom packages and modifications, exported as overlays
overlays = import ./nix/overlays { inherit inputs; };
# Reusable nixos modules you might want to export
# These are usually stuff you would upstream into nixpkgs
nixosModules = import ./nix/modules/nixos;
# Reusable home-manager modules you might want to export
# These are usually stuff you would upstream into home-manager
# homeManagerModules = import ./nix/modules/home-manager;
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#your-hostname'
# or 'nixos-rebuild --flake .' for current hostname
nixosConfigurations = {
# Build a iso image (NixOS installer)
iso = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
modules = [
# "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-gnome.nix"
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
"${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix"
inputs.sops-nix.nixosModules.sops
./hosts/iso
];
};
demovm = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
modules = [
inputs.sops-nix.nixosModules.sops
./hosts/demovm
home-manager.nixosModules.home-manager
{
home-manager = {
backupFileExtension = "hm-backup";
useGlobalPkgs = true;
useUserPackages = true;
verbose = true;
users = {
root = import ./users/root/demovm.nix;
demo = {
imports = [
stylix.homeManagerModules.stylix
./users/demo/demovm.nix
];
};
};
};
}
];
};
b4d14 = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
modules = [
inputs.sops-nix.nixosModules.sops
./hosts/b4d14
home-manager.nixosModules.home-manager
{
home-manager = {
backupFileExtension = "hm-backup";
useGlobalPkgs = true;
useUserPackages = true;
verbose = true;
extraSpecialArgs = { inputs = self.inputs; };
users = {
root = import ./users/root/b4d14.nix;
badele = {
imports = [
nur.nixosModules.nur
stylix.homeManagerModules.stylix
./users/badele/b4d14.nix
];
};
};
};
}
];
};
badxps = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
modules = [
inputs.sops-nix.nixosModules.sops
./hosts/badxps
home-manager.nixosModules.home-manager
{
home-manager = {
backupFileExtension = "hm-backup";
useGlobalPkgs = true;
useUserPackages = true;
verbose = true;
extraSpecialArgs = { inputs = self.inputs; };
users = {
root = import ./users/root/badxps.nix;
badele = {
imports = [
nur.nixosModules.nur
stylix.homeManagerModules.stylix
./users/badele/badxps.nix
];
};
};
};
}
];
};
sadhome = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
modules = [ inputs.sops-nix.nixosModules.sops ./hosts/sadhome ];
};
bootstore = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
modules = [ inputs.sops-nix.nixosModules.sops ./hosts/bootstore ];
};
rpi40 = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
modules = [ inputs.sops-nix.nixosModules.sops ./hosts/rpi40 ];
};
srvhoma = nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs outputs; };
modules = [ inputs.sops-nix.nixosModules.sops ./hosts/srvhoma ];
};
};
# Standalone home-manager configuration entrypoint
# Available through 'home-manager --flake .#your-username@your-hostname'
# or 'home-manager --flake .' for current user in current hostname
homeConfigurations = {
########################################################################
# b4d14
########################################################################
"root@b4d14" = home-manager.lib.homeManagerConfiguration {
pkgs =
nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [
# > Our main home-manager configuration file <
./users/root/b4d14.nix
];
};
"badele@b4d14" = home-manager.lib.homeManagerConfiguration {
pkgs =
nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [
# > Our main home-manager configuration file <
nur.hmModules.nur
./users/badele/b4d14.nix
];
};
########################################################################
# sadhome
########################################################################
"root@sadhome" = home-manager.lib.homeManagerConfiguration {
pkgs =
nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [
# > Our main home-manager configuration file <
./nix/home-manager/users/root/sadhome.nix
];
};
"badele@sadhome" = home-manager.lib.homeManagerConfiguration {
pkgs =
nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [
# > Our main home-manager configuration file <
./users/badele/sadhome.nix
];
};
"sadele@sadhome" = home-manager.lib.homeManagerConfiguration {
pkgs =
nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [
# > Our main home-manager configuration file <
./users/sadele/sadhome.nix
];
};
########################################################################
# rpi40
########################################################################
"badele@rpi40" = home-manager.lib.homeManagerConfiguration {
pkgs =
nixpkgs.legacyPackages.aarch64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [
# > Our main home-manager configuration file <
./users/badele/rpi40.nix
];
};
########################################################################
# srvhoma
########################################################################
"root@srvhoma" = home-manager.lib.homeManagerConfiguration {
pkgs =
nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [
# > Our main home-manager configuration file <
./users/root/srvhoma.nix
];
};
"badele@srvhoma" = home-manager.lib.homeManagerConfiguration {
pkgs =
nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [
# > Our main home-manager configuration file <
nur.hmModules.nur
./users/badele/srvhoma.nix
];
};
########################################################################
# demo
########################################################################
"root@demovm" = home-manager.lib.homeManagerConfiguration {
pkgs =
nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [
# > Our main home-manager configuration file <
./users/root/demo.nix
];
};
"badele@demovm" = home-manager.lib.homeManagerConfiguration {
pkgs =
nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = { inherit inputs outputs; };
modules = [
# > Our main home-manager configuration file <
nur.hmModules.nur
./users/badele/demo.nix
];
};
};
};
}