/
hardware-configuration.nix
103 lines (97 loc) · 2.23 KB
/
hardware-configuration.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
{
lib,
pkgs,
modulesPath,
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
nixpkgs.overlays = let
ubootWithBtrfsAndZstd = oldAttrs: {
extraConfig = ''
CONFIG_CMD_BTRFS=y
CONFIG_ZSTD=y
CONFIG_BOOTCOMMAND="setenv boot_prefixes / /boot/ /@/ /@boot/; run distro_bootcmd;"
'';
};
in [
(self: super: {
ubootRaspberryPi3_64bit = super.ubootRaspberryPi3_64bit.overrideAttrs ubootWithBtrfsAndZstd;
ubootRaspberryPi4_64bit = super.ubootRaspberryPi4_64bit.overrideAttrs ubootWithBtrfsAndZstd;
})
];
boot = {
# console=ttyAMA0 seems necessary for kernel boot messages in qemu
kernelParams = [
"console=ttyS0,115200n8"
"console=ttyAMA0,115200n8"
"console=tty0"
"root=/dev/disk/by-label/NIXOS_SD"
"rootfstype=btrfs"
"rootflags=subvol=@"
"rootwait"
];
initrd.kernelModules = ["zstd" "btrfs"];
loader = {
grub.enable = false;
generic-extlinux-compatible = {
enable = true;
configurationLimit = 20;
};
};
};
fileSystems = let
opts = [
"noatime"
"ssd_spread"
"autodefrag"
"discard=async"
"compress-force=zstd"
];
fsType = "btrfs";
device = "/dev/disk/by-label/NIXOS_SD";
in {
"/" = {
inherit fsType device;
options = opts ++ ["subvol=@"];
};
"/boot" = {
inherit fsType device;
options = opts ++ ["subvol=@boot"];
};
"/gnu" = {
inherit fsType device;
options = opts ++ ["subvol=@gnu"];
};
"/nix" = {
inherit fsType device;
options = opts ++ ["subvol=@nix"];
};
"/var" = {
inherit fsType device;
options = opts ++ ["subvol=@var"];
};
"/home" = {
inherit fsType device;
options = opts ++ ["subvol=@home"];
};
"/.snapshots" = {
inherit fsType device;
options = opts ++ ["subvol=@snapshots"];
};
"/boot/firmware" = {
device = "/dev/disk/by-label/FIRMWARE";
fsType = "vfat";
options = ["nofail" "noauto"];
};
};
zramSwap = {
enable = true;
memoryPercent = 50;
algorithm = "zstd";
};
powerManagement.cpuFreqGovernor =
lib.mkDefault
"ondemand";
}