From eb1c3778b07d66d7ec0d0fd214a59ad93ce524fe Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 27 Apr 2023 22:43:52 +0200 Subject: [PATCH] add disko for chungus --- scripts/disko-config-chungus.nix | 127 +++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 scripts/disko-config-chungus.nix diff --git a/scripts/disko-config-chungus.nix b/scripts/disko-config-chungus.nix new file mode 100644 index 0000000..732c2e3 --- /dev/null +++ b/scripts/disko-config-chungus.nix @@ -0,0 +1,127 @@ +# 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 + +{ raid_disks ? [ + "sda" + "sdb" + "sdc" + "sdd" + "sde" + ] +, ... +}: { + disko.devices = { + disk = { + root = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + type = "partition"; + 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"; + }; + }; + } + ]; + }; + }; + } // listToAttrs + (device_name: + { + name = device_name; + value = { + type = "disk"; + device = "/dev/${device_name}"; + content = { + type = "table"; + format = "gpt"; + partitions = [ + { + name = "zfs"; + start = "0"; + end = "100%"; + content = { + type = "luks"; + name = "raid_${device_name}"; + #keyFile = "/tmp/secret.key"; + content = { + type = "zfs"; + pool = "zraid"; + }; + }; + } + ]; + }; + }; + } + ) + raid_disks; + + zpool = { + + zroot = { + type = "zpool"; + datasets = { + "root" = { + type = "zfs_fs"; + mountpoint = "/"; + }; + }; + }; + + zraid = { + type = "zpool"; + mode = "raidz2"; + datasets = { + "media" = { + type = "zfs_fs"; + mountpoint = "/media"; + }; + "media/nextcloud" = { + type = "zfs_fs"; + mountpoint = "/media/nextcloud"; + options = { + # question: is that combination of frequency and keep even possible? + "com.sun:auto-snapshot" = "false"; + "com.sun:auto-snapshot:daily,keep=32" = "true"; + "com.sun:auto-snapshot:weekly,keep=52" = "true"; + "com.sun:auto-snapshot:montly,keep=24" = "true"; + }; + }; + }; + }; + + }; + + }; +} +