nixos-config/nixos/machines/chungus/disko-config.nix
2023-04-30 00:47:46 +02:00

149 lines
4 KiB
Nix

# nix run github:nix-community/disko -- --mode zap_create_mount ./disko-config.nix
# nixos-generate-config --no-filesystems --root /mnt
# vim /mnt/configuration.nix
# nixos-install
{ ... }:
let
raid_disks = {
"TOSHIBA_1360A003FVGG" = "/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_1360A003FVGG";
"TOSHIBA_1360A00BFVGG" = "/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_1360A00BFVGG";
"TOSHIBA_1360A00VFVGG" = "/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_1360A00VFVGG";
"TOSHIBA_41R0A0EBF57H" = "/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_41R0A0EBF57H";
"TOSHIBA_5120A03WF57H" = "/dev/disk/by-id/ata-TOSHIBA_MG08ACA16TE_5120A03WF57H";
};
in
{
disko.devices = {
disk = {
root = {
type = "disk";
device = "/dev/nvme0n1";
content = {
type = "table";
format = "gpt";
partitions = [
{
name = "ESP";
start = "0";
end = "500MiB";
bootable = true;
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [
"defaults"
];
};
}
{
name = "zfs";
start = "500MiB";
end = "100%";
content = {
type = "luks";
name = "root";
#keyFile = "/root/password"; # keyFile contains the key for encryption, not the passphrase to unlock the key
content = {
type = "zfs";
pool = "zroot";
};
};
}
];
};
};
} // builtins.mapAttrs
(name: device_path: {
type = "disk";
device = device_path;
content = {
type = "table";
format = "gpt";
partitions = [
{
name = "zfs";
start = "0";
end = "100%";
content = {
type = "luks";
name = "raid_${name}";
#keyFile = "/root/password"; # keyFile contains the key for encryption, not the passphrase to unlock the key
content = {
type = "zfs";
pool = "zraid";
};
};
}
];
};
}
)
raid_disks;
zpool = {
zroot = {
type = "zpool";
#rootFsOptions = {
#mountpoint = "none";
#canmount = "off";
#};
datasets = {
"root" = {
type = "zfs_fs";
mountpoint = "/";
options = {
mountpoint = "/";
compression = "lz4";
};
};
};
};
# use boot.zfs.extraPools = [ "zraid" ] to mount this pool during boot time.
# or `zpool import -f zraid` once on the first boot and reboot
zraid = {
type = "zpool";
mode = "raidz2";
rootFsOptions = {
mountpoint = "none";
canmount = "off";
};
datasets = {
"media" = {
type = "zfs_fs";
mountpoint = "/media";
options = {
mountpoint = "/media";
compression = "lz4";
};
};
"nextcloud" = {
type = "zfs_fs";
mountpoint = "/nextcloud";
options = {
mountpoint = "/nextcloud";
compression = "lz4";
"com.sun:auto-snapshot" = "false";
"com.sun:auto-snapshot:daily" = "true,keep=32";
"com.sun:auto-snapshot:montly" = "true,keep=48";
};
};
"borg" = {
type = "zfs_fs";
mountpoint = "/borg";
options = {
mountpoint = "/borg";
compression = "lz4";
"com.sun:auto-snapshot" = "false";
"com.sun:auto-snapshot:daily" = "true,keep=32";
};
};
};
};
};
};
}