124 lines
3.0 KiB
Nix
124 lines
3.0 KiB
Nix
{
|
|
disko.devices = {
|
|
disk = let
|
|
mkDisk = device: mountpoint: {
|
|
type = "disk";
|
|
device = device;
|
|
content = {
|
|
type = "gpt";
|
|
partitions = {
|
|
ESP = {
|
|
size = "1G";
|
|
type = "EF00";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "vfat";
|
|
mountpoint = mountpoint;
|
|
mountOptions = ["nofail"];
|
|
};
|
|
};
|
|
zfs = {
|
|
size = "-4G";
|
|
content = {
|
|
type = "zfs";
|
|
pool = "zroot";
|
|
};
|
|
};
|
|
swap = {
|
|
size = "100%";
|
|
content = {
|
|
type = "swap";
|
|
discardPolicy = "both";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
in {
|
|
root = mkDisk "/dev/sda" "/boot";
|
|
mirror = mkDisk "/dev/sdb" "/boot-fallback";
|
|
};
|
|
zpool = {
|
|
zroot = {
|
|
type = "zpool";
|
|
mode = "mirror";
|
|
rootFsOptions = {
|
|
mountpoint = "none";
|
|
compression = "zstd";
|
|
acltype = "posixacl";
|
|
xattr = "sa";
|
|
"com.sun:auto-snapshot" = "false";
|
|
};
|
|
options.ashift = "12";
|
|
datasets = {
|
|
"root" = {
|
|
type = "zfs_fs";
|
|
options = {
|
|
encryption = "aes-256-gcm";
|
|
keyformat = "passphrase";
|
|
keylocation = "prompt";
|
|
compression = "zstd";
|
|
};
|
|
mountpoint = "/";
|
|
postCheckHook = "zfs snapshot zroot/root@blank";
|
|
};
|
|
"nix" = {
|
|
type = "zfs_fs";
|
|
options = {
|
|
mountpoint = "/nix";
|
|
compression = "zstd";
|
|
};
|
|
mountpoint = "/nix";
|
|
};
|
|
"persist" = {
|
|
type = "zfs_fs";
|
|
options = {
|
|
mountpoint = "/persist";
|
|
compression = "zstd";
|
|
};
|
|
mountpoint = "/persist";
|
|
};
|
|
"s3" = {
|
|
type = "zfs_fs";
|
|
options = {
|
|
mountpoint = "/var/lib/garage/data";
|
|
compression = "lz4";
|
|
};
|
|
mountpoint = "/var/lib/garage/data";
|
|
"com.sun:auto-snapshot" = "false"; # S3/Garage already snapshots
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
fileSystems."/" = {
|
|
device = "zroot/root";
|
|
fsType = "zfs";
|
|
neededForBoot = true;
|
|
options = ["zfsutil"];
|
|
};
|
|
fileSystems."/nix" = {
|
|
device = "zroot/nix";
|
|
fsType = "zfs";
|
|
neededForBoot = true;
|
|
options = ["zfsutil"];
|
|
};
|
|
fileSystems."/persist" = {
|
|
device = "zroot/persist";
|
|
fsType = "zfs";
|
|
neededForBoot = true;
|
|
options = ["zfsutil"];
|
|
};
|
|
fileSystems."/var/lib/garage/data" = {
|
|
device = "zroot/s3";
|
|
fsType = "zfs";
|
|
options = ["zfsutil"];
|
|
};
|
|
fileSystems."/boot-fallback" = {
|
|
device = "/dev/sdb1";
|
|
fsType = "vfat";
|
|
options = ["nofail"];
|
|
};
|
|
}
|