Skip to content

Commit aa26b37

Browse files
committed
feat(hosts/merope): migrate to disko
1 parent 0fa78e5 commit aa26b37

File tree

1 file changed

+89
-35
lines changed

1 file changed

+89
-35
lines changed

hosts/merope/hardware-configuration.nix

Lines changed: 89 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
{
2-
imports = [../common/optional/ephemeral-btrfs.nix];
1+
{inputs, config, ...}: {
2+
imports = [
3+
../common/optional/ephemeral-btrfs.nix
4+
inputs.disko.nixosModules.disko
5+
];
36

47
boot = {
58
initrd = {
@@ -8,42 +11,93 @@
811
loader.timeout = 5;
912
};
1013

11-
fileSystems = {
12-
"/boot" = {
13-
device = "/dev/disk/by-label/BOOT";
14-
fsType = "vfat";
15-
};
16-
17-
"/firmware" = {
18-
device = "/dev/disk/by-label/FIRMWARE";
19-
fsType = "vfat";
20-
};
21-
22-
"/srv/media/tv" = {
23-
device = "/dev/disk/by-label/media";
24-
fsType = "btrfs";
25-
options = [
26-
"subvol=tv"
27-
"noatime"
28-
];
14+
# TODO: migrate to UEFI using (https://github.com/pftf/RPi4), https://wiki.adtya.xyz/nix/nix-on-pi.html
15+
disko.devices.disk = {
16+
main = {
17+
device = "/dev/sdb";
18+
type = "disk";
19+
content = {
20+
type = "gpt";
21+
partitions = {
22+
firmware = {
23+
size = "30M";
24+
content = {
25+
type = "filesystem";
26+
format = "vfat";
27+
extraArgs = ["-F" "16"]; # FAT16
28+
mountpoint = "/firmware";
29+
};
30+
};
31+
root = {
32+
size = "100%-512M";
33+
content = {
34+
type = "btrfs";
35+
postCreateHook = ''
36+
MNTPOINT=$(mktemp -d)
37+
mount -t btrfs "$device" "$MNTPOINT"
38+
trap 'umount $MNTPOINT; rm -d $MNTPOINT' EXIT
39+
btrfs subvolume snapshot -r $MNTPOINT/root $MNTPOINT/root-blank
40+
'';
41+
subvolumes = {
42+
"/root" = {
43+
mountOptions = ["compress=zstd"];
44+
mountpoint = "/";
45+
};
46+
"/nix" = {
47+
mountOptions = ["compress=zstd" "noatime"];
48+
mountpoint = "/nix";
49+
};
50+
"/persist" = {
51+
mountOptions = ["compress=zstd"];
52+
mountpoint = "/persist";
53+
};
54+
"/swap" = {
55+
mountOptions = ["compress=zstd" "noatime"];
56+
mountpoint = "/swap";
57+
swap.swapfile = {
58+
size = "8196M";
59+
path = "swapfile";
60+
};
61+
};
62+
};
63+
};
64+
};
65+
boot = {
66+
size = "512M";
67+
content = {
68+
type = "filesystem";
69+
format = "vfat";
70+
mountpoint = "/boot";
71+
};
72+
};
73+
};
74+
};
2975
};
30-
31-
"/srv/media/movies" = {
32-
device = "/dev/disk/by-label/media";
33-
fsType = "btrfs";
34-
options = [
35-
"subvol=movies"
36-
"noatime"
37-
];
76+
hdd = {
77+
device = "/dev/sda";
78+
type = "disk";
79+
content = {
80+
type = "gpt";
81+
partitions.media = {
82+
size = "100%";
83+
content = {
84+
type = "btrfs";
85+
subvolumes = {
86+
"/tv" = {
87+
mountOptions = ["noatime"];
88+
mountpoint = "/srv/media/tv";
89+
};
90+
"/movies" = {
91+
mountOptions = ["noatime"];
92+
mountpoint = "/srv/media/movies";
93+
};
94+
};
95+
};
96+
};
97+
};
3898
};
3999
};
40-
41-
swapDevices = [
42-
{
43-
device = "/swap/swapfile";
44-
size = 8196;
45-
}
46-
];
100+
fileSystems."/persist".neededForBoot = true;
47101

48102
hardware.raspberry-pi."4" = {
49103
i2c1.enable = true;

0 commit comments

Comments
 (0)