From fbf9accd6e40ea33aa8dfc10613b113fb5abc422 Mon Sep 17 00:00:00 2001 From: Roy Dumblauskas Date: Sun, 27 Apr 2025 14:53:57 -0500 Subject: [PATCH] write first gen impermanence disko-config --- nixos/disk-config.nix | 77 ++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/nixos/disk-config.nix b/nixos/disk-config.nix index 77b56ab..0ee9540 100644 --- a/nixos/disk-config.nix +++ b/nixos/disk-config.nix @@ -1,56 +1,67 @@ +{ disks ? [ "/dev/nvme0n1" ], ... }: { disko.devices = { disk = { - vdb = { + x = { + device = builtins.elemAt disks 0; type = "disk"; - device = "/dev/nvme0n1"; content = { - type = "gpt"; + type = "table"; + format = "gpt"; partitions = { + # boot ESP = { - priority = 1; - name = "ESP"; - start = "1M"; - end = "128M"; - type = "EF00"; + start = "1MiB"; + end = "500MiB"; + bootable = true; content = { type = "filesystem"; format = "vfat"; mountpoint = "/boot"; }; }; - root = { + # root + zfs = { size = "100%"; content = { - type = "btrfs"; - extraArgs = [ "-f" ]; # Override existing partition - # Subvolumes must set a mountpoint in order to be mounted, - # unless their parent is mounted - subvolumes = { - # Subvolume name is different from mountpoint - "/rootfs" = { - mountpoint = "/"; - }; - # Subvolume name is the same as the mountpoint - "/home" = { - mountOptions = [ "compress=zstd" ]; - mountpoint = "/home"; - }; - # Sub(sub)volume doesn't need a mountpoint as its parent is mounted - "/home/elliott" = { }; - # Parent is not mounted so the mountpoint must be set - "/nix" = { - mountOptions = [ "compress=zstd" "noatime" ]; - mountpoint = "/nix"; - }; - }; - - mountpoint = "/partition-root"; + type = "zfs"; + pool = "zroot"; }; }; }; }; }; }; + zpool = { + zroot = { + type = "zpool"; + mode = "mirror"; + options.cachefile = "none"; + rootFsOptions = { + compression = "zstd"; + "com.sun:auto-snapshot" = "false"; + }; + moutpoint = "/"; + postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot@blank$' || zfs snapshot zroot@blank"; + + datasets = { + "nix" = { + type = "zfs_fs"; + options.mountpoint = "/local/nix"; + mountpoint = "/local/nix"; + }; + "home" = { + type = "zfs_fs"; + options.mountpoint = "/safe/home"; + mountpoint = "/safe/home"; + }; + "persist" = { + type = "zfs_fs"; + options.mountpoint = "/safe/persist"; + mountpoint = "/safe/persist"; + }; + }; + }; + }; }; }