infra/nix/hosts/pure-joy/disko-config.nix.old
2026-01-05 23:09:19 +01:00

278 lines
7.7 KiB
Nix

{
config,
lib,
...
}: {
disko.devices = {
disk = {
one = {
type = "disk";
device = "/dev/disk/by-id/ata-WDC_WDS240G2G0A-00JH30_194033801274";
content = {
type = "gpt";
partitions = {
ESP = {
type = "EF00";
size = "1024M";
#content = {
# type = "mdraid";
# name = "boot";
#};
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "zroot";
};
};
}; # partitions
}; # content
}; # disk1
#two = {
# type = "disk";
# device = "/dev/disk/by-id/ata-WDC_WDS240G2G0A-00JH30_1939A1801207";
# content = {
# type = "gpt";
# partitions = {
# ESP = {
# type = "EF00";
# size = "1024M";
# #content = {
# # type = "mdraid";
# # name = "boot";
# #};
# content = {
# type = "filesystem";
# format = "vfat";
# mountpoint = "/boot2";
# };
# };
# zfs = {
# size = "100%";
# content = {
# type = "zfs";
# pool = "zroot";
# };
# };
# }; # partitions
# }; # content
#}; # disk2
};
#mdadm = {
# boot = {
# type = "mdadm";
# level = 1;
# metadata = "1.0";
# content = {
# type = "filesystem";
# format = "vfat";
# mountpoint = "/boot";
# };
# };
#};
zpool = {
zroot = {
type = "zpool";
# mode = "mirror";
mode = ""; # single disk
options = {
ashift = "12";
autotrim = "on";
# canmount = "off";
};
rootFsOptions = {
# mountpoint = "none";
# canmount = "off";
dnodesize = "auto";
xattr = "sa";
relatime = "on";
# atime = "off";
encryption = "aes-256-gcm";
keyformat = "passphrase";
keylocation = "file:///root/.zfs-zroot-pool.key";
# "zfs change-key -o keylocation=prompt zroot/$name"
#postCreateHook = ''
# "zfs change-key -o keylocation=prompt zroot"
#'';
checksum = "blake3";
compression = "zstd";
"com.sun:auto-snapshot" = "false";
};
mountpoint = null;
# postCreateHook = "zfs snapshot zroot@blank";
postCreateHook = "zfs snapshot zroot@blank; zfs set keylocation=prompt zroot";
#postCreateHook = ''
# zfs snapshot zroot@blank
# zfs change-key -o keylocation=prompt zroot"
#'';
datasets = {
reserved = {
type = "zfs_fs";
mountpoint = null;
options = {
refreservation = "10G";
};
};
# can be rebuilt.
local = {
type = "zfs_fs";
mountpoint = null;
options = {
canmount = "noauto";
"com.sun:auto-snapshot" = "false";
};
};
"local/nix" = {
type = "zfs_fs";
mountpoint = "/nix";
options = {
"recordsize" = "1M";
};
};
"local/mnt" = {
type = "zfs_fs";
mountpoint = "/mnt";
};
"local/home" = {
type = "zfs_fs";
mountpoint = "/home";
options = {
canmount = "noauto";
"com.sun:auto-snapshot" = "false";
};
};
"local/home/root-cache" = {
type = "zfs_fs";
mountpoint = "/root/.cache";
options."com.sun:auto-snapshot" = "false";
};
"local/home/root-xper" = {
type = "zfs_fs";
mountpoint = "/root/xper";
options."com.sun:auto-snapshot" = "false";
};
"local/home/root-npm-packages" = {
type = "zfs_fs";
mountpoint = "/root/.npm-packages";
options."com.sun:auto-snapshot" = "false";
};
"local/var-cache" = {
type = "zfs_fs";
mountpoint = "/var/cache";
options = {
"com.sun:auto-snapshot" = "true";
"recordsize" = "1M";
};
};
"local/var-containers-storage" = {
type = "zfs_fs";
mountpoint = "/var/lib/containers/storage";
options = {
"com.sun:auto-snapshot" = "false";
acltype = "posixacl";
};
};
"system" = {
type = "zfs_fs";
mountpoint = null;
options = {
"com.sun:auto-snapshot" = "false";
};
};
# system root.
"system/nixos" = {
type = "zfs_fs";
mountpoint = "/";
options = {
"com.sun:auto-snapshot" = "true";
};
};
"system/nixos/var" = {
type = "zfs_fs";
# mountpoint = "/var";
options = {
"com.sun:auto-snapshot" = "true";
"recordsize" = "1M"; # faster sequential reads.
};
};
"system/nixos/var/log" = {
type = "zfs_fs";
# mountpoint = "/var/log";
options = {
"com.sun:auto-snapshot" = "true";
"recordsize" = "1M"; # faster sequential reads.
};
};
# frequently snapshot and backed up data.
userdata = {
type = "zfs_fs";
mountpoint = "/DATA";
options = {
# encryption = "aes-256-gcm";
# keyformat = "passphrase";
# keylocation = "file:///root/.zfs-DATA.key";
"com.sun:auto-snapshot" = "false";
};
};
"userdata/home" = {
type = "zfs_fs";
# mountpoint = "/home";
mountpoint = null;
options = {
# encryption = "aes-256-gcm";
# keyformat = "passphrase";
# keylocation = "file:///root/.zfs-DATA-home.key";
"com.sun:auto-snapshot" = "false";
};
};
"userdata/home/root" = {
type = "zfs_fs";
mountpoint = "/root";
options = {
"com.sun:auto-snapshot" = "true";
};
};
"userdata/home/root-config" = {
type = "zfs_fs";
mountpoint = "/root/.config";
options = {
"com.sun:auto-snapshot" = "true";
};
};
"userdata/home/root-src" = {
type = "zfs_fs";
mountpoint = "/root/src";
options = {
"com.sun:auto-snapshot" = "true";
};
};
"userdata/home/root-atuin" = {
type = "zfs_volume";
size = "1G";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/root/.local/share/atuin";
};
};
"userdata/services" = {
type = "zfs_fs";
mountpoint = "/DATA/services";
options = {
"com.sun:auto-snapshot" = "false";
"recordsize" = "1M"; # faster sequential reads.
};
};
};
};
};
};
}