239 lines
6.7 KiB
Nix
239 lines
6.7 KiB
Nix
{
|
|
config,
|
|
disks ? ["/dev/sda"],
|
|
lib,
|
|
username,
|
|
...
|
|
}: {
|
|
disko.devices = {
|
|
disk = {
|
|
nvme0n1 = {
|
|
type = "disk";
|
|
device = "/dev/sda";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
ESP = {
|
|
type = "EF00";
|
|
size = "1G";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "vfat";
|
|
mountpoint = "/boot";
|
|
};
|
|
};
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
zpool = {
|
|
zroot = {
|
|
type = "zpool";
|
|
mode = ""; # == single disk
|
|
options = {
|
|
ashift = "12";
|
|
autotrim = "on";
|
|
};
|
|
rootFsOptions = {
|
|
encryption = "aes-256-gcm";
|
|
keyformat = "passphrase";
|
|
keylocation = "file:///root/.zfs-zroot-pool.key";
|
|
postCreateHook = ''
|
|
zfs change-key -o keylocation=prompt zroot
|
|
'';
|
|
checksum = "blake3";
|
|
atime = "off";
|
|
compression = "zstd";
|
|
"com.sun:auto-snapshot" = "false";
|
|
};
|
|
mountpoint = null;
|
|
postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot@blank$' || zfs snapshot zroot@blank";
|
|
|
|
datasets = {
|
|
# can be rebuilt.
|
|
local = {
|
|
type = "zfs_fs";
|
|
mountpoint = null;
|
|
options = {
|
|
canmount = "noauto";
|
|
"com.sun:auto-snapshot" = "false";
|
|
};
|
|
};
|
|
"local/nix" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/nix";
|
|
};
|
|
"local/mnt" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/mnt";
|
|
};
|
|
"local/home" = {
|
|
type = "zfs_fs";
|
|
# mountpoint = "/home";
|
|
mountpoint = null;
|
|
options = {
|
|
canmount = "no";
|
|
"com.sun:auto-snapshot" = "false";
|
|
};
|
|
};
|
|
"local/home/${username}" = {
|
|
type = "zfs_fs";
|
|
mountpoint = null;
|
|
options = {
|
|
canmount = "off";
|
|
"com.sun:auto-snapshot" = "false";
|
|
};
|
|
};
|
|
"local/home/${username}/npm-packages" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/home/${username}/.npm-packages";
|
|
options."com.sun:auto-snapshot" = "false";
|
|
};
|
|
"local/home/${username}/.cache" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/home/${username}/.cache";
|
|
options."com.sun:auto-snapshot" = "false";
|
|
};
|
|
"local/home/${username}/xper" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/home/${username}/xper";
|
|
options."com.sun:auto-snapshot" = "true";
|
|
};
|
|
"local/home/root-cache" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/root/.cache";
|
|
options."com.sun:auto-snapshot" = "false";
|
|
};
|
|
"local/var-cache" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/var/cache";
|
|
options = {
|
|
"com.sun:auto-snapshot" = "true";
|
|
};
|
|
};
|
|
"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";
|
|
};
|
|
};
|
|
"system/nixos/var/log" = {
|
|
type = "zfs_fs";
|
|
# mountpoint = "/var/log";
|
|
options = {
|
|
"com.sun:auto-snapshot" = "true";
|
|
};
|
|
};
|
|
# 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";
|
|
canmount = "no";
|
|
};
|
|
};
|
|
"userdata/home/${username}" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/home/${username}";
|
|
options = {
|
|
"com.sun:auto-snapshot" = "true";
|
|
};
|
|
};
|
|
"userdata/home/${username}/Documents" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/home/${username}/Downloads" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/home/${username}/src" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/home/${username}/sync" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/home/${username}/void" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/home/${username}/.config" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/home/${username}/.local-share-atuin-zvol" = {
|
|
type = "zfs_volume";
|
|
size = "300M";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "ext4";
|
|
mountpoint = "/home/${username}/.local/share/atuin";
|
|
};
|
|
};
|
|
"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/services" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/DATA/services";
|
|
options."com.sun:auto-snapshot" = "false";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|