-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
458 lines (418 loc) · 15.6 KB
/
flake.nix
File metadata and controls
458 lines (418 loc) · 15.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
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
{
description = "DOTS";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/release-25.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
home-manager.url = "github:nix-community/home-manager/release-25.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
nixos-hardware.url = "github:NixOS/nixos-hardware";
impermanence.url = "github:nix-community/impermanence";
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
lanzaboote = {
url = "github:nix-community/lanzaboote";
inputs.nixpkgs.follows = "nixpkgs";
};
comin = {
url = "github:nlewo/comin";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
nirif = {
url = "github:sodiboo/niri-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
dots.url = "/home/dio/.daddy/dots-dev/";
dots.inputs.nixpkgs.follows = "nixpkgs";
# Temporarily remove dots-framework input until technical issues are resolved
# dots.url = "git+file:///home/shift/code/dots-framework";
# dots.inputs.nixpkgs.follows = "nixpkgs";
# Software inputs
dots-notifier = {
url = "github:shift/dots-notifier";
inputs.nixpkgs.follows = "nixpkgs";
};
dots-wallpaper = {
url = "github:shift/dots-wallpaper";
inputs.nixpkgs.follows = "nixpkgs";
};
geoclue-prometheus-exporter = {
url = "github:shift/geoclue-prometheus-exporter";
inputs.nixpkgs.follows = "nixpkgs";
};
nixvim = {
url = "github:nix-community/nixvim/nixos-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
nixd = {
url = "github:nix-community/nixd";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-minecraft = {
url = "github:Infinidoge/nix-minecraft";
inputs.nixpkgs.follows = "nixpkgs";
};
# BLING!
stylix.url = "github:nix-community/stylix/release-25.11";
stylix.inputs.nixpkgs.follows = "nixpkgs";
niri = {
url = "github:YaLTeR/niri";
inputs.nixpkgs.follows = "nixpkgs";
};
# Devshell
treefmt-nix.url = "github:numtide/treefmt-nix";
};
nixConfig = {
extra-substituters = [
"https://cache.garnix.io"
"https://shift.cachix.org"
"https://nix-community.cachix.org"
"https://nixpkgs-unfree.cachix.org"
];
extra-trusted-public-keys = [
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"shift.cachix.org-1:GfqZjV2WglCFobSSZ+l+IH2ojrY8LyJVA6cMmgVVBgk="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"nixpkgs-unfree.cachix.org-1:hqvoInulhbV4nJ9yJOEr+4wxhDV4xq2d1DK7S6Nj6rs="
];
};
outputs =
inputs@{
self,
nixpkgs,
nixpkgs-unstable,
nixos-hardware,
lanzaboote,
impermanence,
home-manager,
nixvim,
nixos-generators,
disko,
niri,
nirif,
dots,
...
}:
let
system = "x86_64-linux";
pkgs-unstable = nixpkgs-unstable.legacyPackages.x86_64-linux;
in
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-darwin"
"aarch64-linux"
];
imports = [
inputs.treefmt-nix.flakeModule
nixos-generators.nixosModules.all-formats
./nixos
];
flake = {
# Configurations for Linux (NixOS) systems
nixosConfigurations = {
shulkerbox = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
inherit pkgs-unstable;
};
modules = [
# Add any other custom nixos-hardware modules required here.
nixos-hardware.nixosModules.lenovo-thinkpad-x250
nixos-hardware.nixosModules.common-pc-ssd
# The following is used for partitioning of drives during the installation.
inputs.disko.nixosModules.disko
impermanence.nixosModules.impermanence
inputs.sops-nix.nixosModules.sops
inputs.comin.nixosModules.comin
home-manager.nixosModules.home-manager
nixvim.nixosModules.nixvim
inputs.stylix.nixosModules.stylix
inputs.nirif.nixosModules.niri
inputs.geoclue-prometheus-exporter.nixosModules.default
inputs.dots-notifier.nixosModules.x86_64-linux.notifier
{
nixpkgs.config.allowUnfree = true;
stylix.enable = true;
stylix.autoEnable = true;
stylix.image = ./assets/wallpaper.jpg;
stylix.targets.plymouth.logo = ./assets/wallpaper.jpg;
stylix.targets.plymouth.logoAnimated = false;
stylix.polarity = "dark";
stylix.opacity = {
terminal = 0.5;
popups = 0.5;
desktop = 0.5;
};
stylix.targets.grub.useImage = true;
# Disable Qt themes to avoid Plasma 5 reference
stylix.targets.qt.enable = false;
fileSystems."/persist".neededForBoot = true;
#services.btrfs.autoScrub.enable = true;
services.qemuGuest.enable = true;
# Install niri system-wide
environment.systemPackages = [
inputs.niri.packages.${system}.niri
];
}
./modules
inputs.dots-wallpaper.nixosModules.default
{
dots.wallpaper = {
enable = true;
width = 1366; # Configure for your screen
height = 768; # Configure for your screen
flakeRootDefault = ./assets/wallpaper.jpg;
};
}
./disks/shulkerbox/disko.nix
./hosts/shulkerbox.nix
./nixos/secureboot.nix
./nixos/comin.nix
./nixos/ssh-tpm-agent.nix
./nixos/laptop/suspend-and-hibernate.nix
];
};
shulkerbox-installer = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
inherit pkgs-unstable;
};
inherit system;
modules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"
nixos-hardware.nixosModules.common-cpu-intel
nixos-hardware.nixosModules.common-pc-ssd
impermanence.nixosModules.impermanence
lanzaboote.nixosModules.lanzaboote
(
{
pkgs,
lib,
...
}:
{
# Ensure this is a NixOS ISO configuration
#boot.kernelPackages = lib.mkForce pkgs.linuxPackages_latest;
#boot.zfs.enabled = lib.mkForce false;
# Networking for installation
networking = {
networkmanager.enable = true;
wireless.enable = false;
};
# Essential tools for installation
environment.systemPackages = with pkgs; [
git
vim
wget
curl
nixos-anywhere
disko
sbctl
util-linux
xxd
file
openssh
# Interactive TUI tools
gum
bun # For interactive guidance
# TPM and hardware detection
tpm2-tools
dmidecode
lshw
# Archive and compression tools
p7zip
# SOPS and secure boot tools
sops
# SOPS and SSH-to-AGE tools for new host setup
sops
ssh-to-age
qrencode # For QR code generation
];
# SSH for remote access
services.openssh = {
enable = true;
settings = {
PermitRootLogin = "yes";
PasswordAuthentication = true;
};
};
# Temporary root access (override any conflicting password settings)
users.users.root = {
initialPassword = lib.mkForce "nixos"; # CHANGE IMMEDIATELY
openssh.authorizedKeys.keys = [
# Add your SSH public key here
];
};
# Allow passwordless sudo
security.sudo.wheelNeedsPassword = false;
# Ensure installer scripts are executable
system.activationScripts.makeInstallerScriptsExecutable = ''
if [ -d /installer-scripts ]; then
chmod +x /installer-scripts/*.sh
# Create convenient symlinks in /usr/local/bin
mkdir -p /usr/local/bin
ln -sf /installer-scripts/shulker-autoinstall.sh /usr/local/bin/shulker-install
ln -sf /installer-scripts/detect-setup-mode.sh /usr/local/bin/check-setup-mode
ln -sf /installer-scripts/install-secureboot-keys.sh /usr/local/bin/install-secureboot
fi
'';
# ISO-specific configuration
system.stateVersion = lib.mkForce "25.05";
# Create convenient aliases for installer scripts
environment.shellAliases = {
shulker-install = "/installer-scripts/shulker-autoinstall.sh";
shulker-status = "/installer-scripts/shulker-autoinstall.sh status";
setup-sops = "/installer-scripts/shulker-autoinstall.sh setup-sops";
install-secureboot = "/installer-scripts/install-secureboot-keys.sh";
check-setup-mode = "/installer-scripts/detect-setup-mode.sh";
};
# Add installer message to motd
users.motd = ''
Welcome to Shulker Installer!
Quick Commands:
shulker-install - Full automated installation
shulker-status - Check system status
setup-sops - Set up SOPS for new host (with QR code)
install-secureboot - Install secure boot keys
check-setup-mode - Check if in setup mode
For help: shulker-install --help
'';
# Optional auto-installer service (disabled by default)
systemd.services.shulker-auto-installer = {
description = "Shulker Auto Installer Service";
wantedBy = [ ]; # Disabled by default - enable with: systemctl enable shulker-auto-installer
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "/installer-scripts/shulker-autoinstall.sh install";
StandardOutput = "journal+console";
StandardError = "journal+console";
};
};
# Explicitly configure the ISO image
isoImage = {
# Customize ISO naming
isoName = "shulkerbox-installer-${lib.substring 0 8 (self.rev or "dirty")}.iso";
# The following is a trade off of time vs size. 3 seems to give a rather decent compressioon given the time it takes.
squashfsCompression = "zstd -Xcompression-level 3";
# Add current repository to the ISO
contents = [
{
source = ./.;
target = "/repo";
}
{
source = ./installer-scripts;
target = "/installer-scripts";
}
{
source = ./secrets/secureboot;
target = "/secureboot";
}
];
};
}
)
inputs.sops-nix.nixosModules.sops
home-manager.nixosModules.home-manager
nixvim.nixosModules.nixvim
inputs.stylix.nixosModules.stylix
{
nixpkgs.config.allowUnfree = true;
stylix.enable = true;
stylix.autoEnable = true;
stylix.image = ./assets/wallpaper.jpg;
stylix.targets.plymouth.logo = ./assets/wallpaper.jpg;
stylix.targets.plymouth.logoAnimated = false;
stylix.polarity = "dark";
stylix.opacity = {
terminal = 0.95;
popups = 0.95;
desktop = 0.5;
};
stylix.targets.grub.useImage = true;
}
#./hosts/shulkerbox.nix
];
};
};
};
perSystem =
{
pkgs,
...
}:
{
# NOTE: These overlays apply to the Nix shell only. See `nix.nix` for
# system overlays.
# _module.args.pkgs = import inputs.nixpkgs {
# inherit system;
# };
#
# treefmt.config = {
# projectRootFile = "flake.nix";
# programs.nixpkgs-fmt.enable = true;
# };
#
# packages.default = self'.packages.activate;
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.git
pkgs.nixpkgs-fmt
pkgs.sops
pkgs.ssh-to-age
pkgs.nixfmt-rfc-style
pkgs.treefmt
pkgs.nixos-generators
];
};
treefmt = {
# Used to find the project root
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = pkgs.lib.meta.availableOn pkgs.stdenv.buildPlatform pkgs.nixfmt-rfc-style.compiler;
nixfmt.package = pkgs.nixfmt-rfc-style;
shellcheck.enable = true;
shfmt.enable = true;
# Respect editorconfig
shfmt.indent_size = null;
statix.enable = true;
deadnix.enable = true;
prettier.enable = true;
taplo.enable = true;
};
settings = {
global.excludes = [
"*.lock"
"*.rst"
"*.md"
"*.png"
"*.po"
"*.mp3"
"*.yaml"
];
formatter = {
# Doesn't support setext headers amongst other things
prettier.excludes = [ "*.md" ];
shellcheck = {
excludes = [
".envrc"
"quodlibet.bash"
];
};
};
};
};
};
};
}