248 lines
7.1 KiB
Nix
248 lines
7.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}: {
|
|
disko.devices = {
|
|
disk = {
|
|
one = {
|
|
type = "disk";
|
|
# device = "/dev/disk/by-id/usb-Verbatim_STORE_N_GO_07B50C09D3E5B1CC-0:0";
|
|
device = "/dev/disk/by-id/ata-WDC_WDS240G2G0A-00JH30_19461B800819";
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
ESP = {
|
|
type = "EF00";
|
|
size = "1G";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "vfat";
|
|
mountpoint = "/boot";
|
|
};
|
|
};
|
|
zfs = {
|
|
size = "100%";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zr";
|
|
};
|
|
};
|
|
}; # partitions
|
|
}; # content
|
|
}; # disk1
|
|
};
|
|
zpool = {
|
|
zr = {
|
|
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-zr-pool.key";
|
|
keylocation = "prompt";
|
|
# "zfs change-key -o keylocation=prompt zr/$name"
|
|
#postCreateHook = ''
|
|
# "zfs change-key -o keylocation=prompt zr"
|
|
#'';
|
|
checksum = "blake3";
|
|
compression = "zstd";
|
|
"com.sun:auto-snapshot" = "false";
|
|
};
|
|
mountpoint = null;
|
|
postCreateHook = "zfs snapshot zr@blank; zfs set keylocation=prompt zr";
|
|
|
|
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";
|
|
# nix doesn't use atime.
|
|
"atime" = "off";
|
|
};
|
|
};
|
|
"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";
|
|
};
|
|
};
|
|
"local/var-lib-docker" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/var/lib/docker";
|
|
options = {
|
|
"com.sun:auto-snapshot" = "false";
|
|
acltype = "posixacl";
|
|
};
|
|
mountOptions = ["x-systemd.mount-timeout=45s" "nofail"];
|
|
};
|
|
"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";
|
|
"acltype" = "posixacl";
|
|
"xattr" = "sa";
|
|
};
|
|
};
|
|
# 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";
|
|
};
|
|
# mountOptions = "x-systemd.device-timeout=30s,x-systemd.mount-timeout=45s,nofail";
|
|
mountOptions = [
|
|
"x-systemd.device-timeout=30s"
|
|
"x-systemd.mount-timeout=45s"
|
|
"nofail"
|
|
];
|
|
};
|
|
"userdata/services" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/DATA/services";
|
|
options = {
|
|
"com.sun:auto-snapshot" = "false";
|
|
# "recordsize" = "1M"; # faster sequential reads.
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|