nixos-config/scripts/disko-config-chungus.nix

125 lines
3.2 KiB
Nix
Raw Normal View History

2023-04-27 22:43:52 +02:00
# nix run github:nix-community/disko -- --mode create ./disko-config-chungus.nix --dry-run
# nix run github:nix-community/disko -- --mode mount ./disko-config-chungus.nix --dry-run
# nixos-generate-config --root /mnt/
# vim /mnt/configuration.nix
# nixos-install --root /mnt
2023-04-28 12:57:48 +02:00
{ ... }:
2023-04-28 09:02:11 +02:00
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
{
2023-04-27 22:43:52 +02:00
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 = "/tmp/secret.key";
content = {
type = "zfs";
pool = "zroot";
};
};
}
];
};
};
2023-04-28 12:57:48 +02:00
} // 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 = "/tmp/secret.key";
content = {
type = "zfs";
pool = "zraid";
};
};
}
];
};
}
2023-04-27 22:43:52 +02:00
)
raid_disks;
zpool = {
zroot = {
type = "zpool";
datasets = {
"root" = {
type = "zfs_fs";
mountpoint = "/";
2023-04-28 12:57:48 +02:00
options.compression = "lz4";
2023-04-27 22:43:52 +02:00
};
};
};
zraid = {
type = "zpool";
mode = "raidz2";
datasets = {
"media" = {
type = "zfs_fs";
mountpoint = "/media";
2023-04-28 12:57:48 +02:00
options.compression = "lz4";
2023-04-27 22:43:52 +02:00
};
"media/nextcloud" = {
type = "zfs_fs";
mountpoint = "/media/nextcloud";
options = {
2023-04-28 12:57:48 +02:00
compression = "lz4";
2023-04-27 22:43:52 +02:00
# question: is that combination of frequency and keep even possible?
"com.sun:auto-snapshot" = "false";
"com.sun:auto-snapshot:daily,keep=32" = "true";
2023-04-28 12:57:48 +02:00
"com.sun:auto-snapshot:montly,keep=48" = "true";
2023-04-27 22:43:52 +02:00
};
};
};
};
};
};
}