238 lines
6.4 KiB
Nix
238 lines
6.4 KiB
Nix
{
|
|
config,
|
|
disks ? [ "/dev/sda" ],
|
|
lib,
|
|
username ? "wan",
|
|
...
|
|
}:
|
|
let
|
|
usrHome = "home/${username}";
|
|
in
|
|
{
|
|
disko.devices = {
|
|
disk = {
|
|
sda = {
|
|
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 = {
|
|
checksum = "blake3";
|
|
atime = "off";
|
|
compression = "zstd";
|
|
"com.sun:auto-snapshot" = "false";
|
|
};
|
|
mountpoint = null;
|
|
postCreateHook = "zfs snapshot zroot@blank";
|
|
|
|
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";
|
|
};
|
|
"local/mnt" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/mnt";
|
|
};
|
|
"local/home" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/home";
|
|
options = {
|
|
canmount = "noauto";
|
|
"com.sun:auto-snapshot" = "false";
|
|
};
|
|
};
|
|
"local/${usrHome}" = {
|
|
type = "zfs_fs";
|
|
mountpoint = null;
|
|
options = {
|
|
canmount = "off";
|
|
"com.sun:auto-snapshot" = "false";
|
|
};
|
|
};
|
|
"local/${usrHome}/npm-packages" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/${usrHome}/.npm-packages";
|
|
options."com.sun:auto-snapshot" = "false";
|
|
};
|
|
"local/${usrHome}/.cache" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/${usrHome}/.cache";
|
|
options."com.sun:auto-snapshot" = "false";
|
|
};
|
|
"local/${usrHome}/xper" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/${usrHome}/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";
|
|
};
|
|
};
|
|
"userdata/${usrHome}" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/${usrHome}";
|
|
options = {
|
|
"com.sun:auto-snapshot" = "true";
|
|
};
|
|
};
|
|
"userdata/${usrHome}/Documents" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/${usrHome}/Downloads" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/${usrHome}/src" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/${usrHome}/sync" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/${usrHome}/.config" = {
|
|
type = "zfs_fs";
|
|
};
|
|
"userdata/${usrHome}/atuin" = {
|
|
type = "zfs_fs";
|
|
mountpoint = "/${usrHome}/.local/share/atuin";
|
|
options = {
|
|
"com.sun:auto-snapshot" = "true";
|
|
"sync" = "disabled";
|
|
};
|
|
};
|
|
"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";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|