server-configuration/disko.nix

99 lines
2.2 KiB
Nix

{
lib,
root-disk ? "Expected a mf disk brother",
raid-disks ? "Expected disks for raid",
...
}: {
disko.devices = {
disk =
{
root = {
type = "disk";
device = root-disk;
content = {
type = "gpt";
partitions = {
boot = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = ["umask=0077"];
};
};
root = {
size = "100%";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
};
# disk2 = {
# type = "disk";
# device = "/dev/my-disk2";
# content = {
# type = "gpt";
# partitions = {
# boot = {
# size = "1M";
# type = "EF02"; # for grub MBR
# };
# mdadm = {
# size = "100%";
# content = {
# type = "mdraid";
# name = "raid1";
# };
# };
# };
# };
# };
}
// lib.attrsets.genAttrs raid-disks (name: {
type = "disk";
device = "/dev" + name;
content = {
type = "gpt";
partitions = {
zfs = {
size = "100%";
content = {
type = "zfs";
pool = "zraid";
};
};
};
};
});
zpool = lib.mkIf (builtins.length raid-disks > 0) {
zraid = {
type = "zpool";
mode = "raidz";
# TODO: Cache-ing
rootFsOptions = {
compression = "zstd";
"com.sun:auto-snapshot" = "false";
};
datasets = {
var = {
type = "zfs_fs";
mountpoint = "/var";
};
home = {
type = "zfs_fs";
mountpoint = "/home";
};
};
};
};
};
}