diff --git a/machines/renoir/disko.nix b/machines/renoir/disko.nix index e01292c..ad3edd6 100644 --- a/machines/renoir/disko.nix +++ b/machines/renoir/disko.nix @@ -1,15 +1,10 @@ # --- -# schema = "btrfs-single-disk-subvolumes-impermanance-rollback" +# schema = "btrfs-single-disk-subvolumes" # [placeholders] # mainDisk = "/dev/disk/by-id/nvme-CT1000P3PSSD8_2313E6C35BC1" # --- # This file was automatically generated! # CHANGING this configuration requires wiping and reinstalling the machine -{ config, ... }: -let - # Adjust, to match the partition's priority. - rootPartition = "${config.disko.devices.disk."main".device}-part3"; -in { boot.loader.grub = { efiInstallAsRemovable = true; @@ -19,7 +14,7 @@ in disko.devices = { disk = { "main" = { - name = "main-af36cf221b9a469888f67f3404be01a5"; + name = "main-d15332ecbf8b4063adcbfbebda63a3a8"; device = "/dev/disk/by-id/nvme-CT1000P3PSSD8_2313E6C35BC1"; type = "disk"; content = { @@ -33,7 +28,6 @@ in "ESP" = { type = "EF00"; size = "500M"; - priority = 2; content = { type = "filesystem"; format = "vfat"; @@ -41,9 +35,15 @@ in mountOptions = [ "umask=0077" ]; }; }; + #"swap" = { + # size = "8G"; # adjust + # content = { + # type = "swap"; + # discardPolicy = "both"; + # }; + #}; "root" = { size = "100%"; - priority = 3; content = { type = "btrfs"; extraArgs = [ @@ -66,74 +66,15 @@ in mountpoint = "/home"; mountOptions = [ "compress=zstd" ]; }; - "@persist" = { - mountpoint = "/persist"; - mountOptions = [ "compress=zstd" ]; - }; }; }; }; - #"swap" = { - # size = "8G"; # adjust - # content = { - # type = "swap"; - # discardPolicy = "both"; - # }; - #}; }; }; }; }; }; - fileSystems."/persist".neededForBoot = true; - - # https://www.notashelf.dev/posts/impermanence/#impermanence - boot.initrd.systemd = { - enable = true; - services.rollback = { - description = "Rollback BTRFS root drive to a pristine state"; - - wantedBy = [ "initrd.target" ]; - after = [ "initrd-root-device.target" ]; - before = [ "sysroot.mount" ]; - - unitConfig.DefaultDependencies = "no"; - serviceConfig.Type = "oneshot"; - script = '' - echo "Mounting root btrfs drive..." - mkdir --parents /mnt - mount --options "subvol=/" ${rootPartition} /mnt - - if [[ -e /mnt/@root ]]; then - mkdir --parents /mnt/root.old.d - timestamp=$(date --date="@$(stat --format=%Y /mnt/@root)" "+%Y-%m-%dT%H:%M:%S") - echo "Moving @root to 'root.old.d/$timestamp'..." - mv /mnt/@root "/mnt/root.old.d/$timestamp" - fi - - delete_subvolume_recursively() { - IFS=$'\n' - for subvolume in $(btrfs subvolume list -o "$1" | cut --fields 9- --delimiter ' '); do - delete_subvolume_recursively "/mnt/$subvolume" - done - echo "Deleting subvolume '$subvolume'..." - btrfs subvolume delete "$1" - } - echo "Deleting very old subvolumes..." - for subvolume in $(find /mnt/root.old.d/ -maxdepth 1 -mtime +30); do - delete_subvolume_recursively "$subvolume" - done - - echo "Creating new empty subvolume @root..." - btrfs subvolume create /mnt/@root - - echo "Finished successfully. Unmounting..." - umount /mnt - ''; - }; - }; - # Automatic local snapshots # https://digint.ch/btrbk/doc/readme.html #$ systemctl start btrbk- @@ -152,20 +93,10 @@ in onCalendar = "*/2:00"; settings = { subvolume = "/home"; - snapshot_create = "onchange"; snapshot_dir = "/home"; snapshot_preserve = "16h 7d 3w 2m"; snapshot_preserve_min = "3d"; }; }; - instances."persist" = { - onCalendar = "*/2:00"; - settings = { - subvolume = "/persist"; - snapshot_dir = "/persist"; - snapshot_preserve = "16h 7d 3w 2m"; - snapshot_preserve_min = "3d"; - }; - }; }; }