nix/framework/disko-zfs.nix
2025-04-21 14:46:03 -07:00

110 lines
2.8 KiB
Nix

# Config for framework 16
# sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount disko.nix
{
disko.devices = {
disk = {
nvme0n1 = {
type = "disk";
device = "/dev/nvme0n1";
content = {
type = "gpt";
partitions = {
ESP = {
name = "ESP";
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
swap = {
size = "70G";
content = {
type = "swap";
randomEncryption = true;
};
};
crypt = {
size = "100%";
content = {
type = "luks";
name = "crypt";
extraOpenArgs = [ "--allow-discards" ];
passwordFile = "/tmp/secret.key";
content = {
type = "zfs";
pool = "rpool";
};
};
};
};
};
};
};
zpool = {
rpool = {
type = "zpool";
rootFsOptions = {
canmount = "off";
mountpoint = "none";
acltype = "posixacl";
compression = "lz4";
dnodesize = "auto";
normalization = "formD";
relatime = "on";
xattr = "sa";
};
options = {
ashift = "12";
autotrim = "on";
};
datasets = {
"local/root" = {
type = "zfs_fs";
options = {
mountpoint = "legacy";
canmount = "noauto";
};
mountpoint = "/";
postCreateHook = ''
zfs snapshot rpool/local/root@blank
'';
};
"local/nix" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/nix";
};
"safe/persist" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/persist";
};
"safe/home" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/home";
postCreateHook = ''
zfs snapshot rpool/safe/home@blank
'';
};
"local/var" = {
type = "zfs_fs";
};
"local/var/lib" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/var/lib";
};
"local/var/log" = {
type = "zfs_fs";
options.mountpoint = "legacy";
mountpoint = "/var/log";
};
};
};
};
};
}