diff --git a/common/nix.nix b/common/nix.nix index 59a5b86..44a8c44 100644 --- a/common/nix.nix +++ b/common/nix.nix @@ -8,6 +8,8 @@ ]; auto-optimise-store = true; experimental-features = [ "nix-command" "flakes" "auto-allocate-uids" "cgroups" "ca-derivations" ]; + auto-allocate-uids = true; + use-cgroups = true; }; nixpkgs.config.allowUnfree = true; } diff --git a/hosts/skipper/rollback.nix b/hosts/skipper/rollback.nix new file mode 100644 index 0000000..94e76b4 --- /dev/null +++ b/hosts/skipper/rollback.nix @@ -0,0 +1,27 @@ +{ lib, ... }: { + boot.initrd.postDeviceCommands = lib.mkBefore '' + mkdir -p /mnt + mount -o subvol=/ /dev/vg0/system /mnt + + btrfs subvolume list -o /mnt | + cut -f9 -d' ' | + while read subvolume; do + echo "deleting /$subvolume subvolume..." + btrfs subvolume delete "/mnt/$subvolume" + done && + echo "deleting /root subvolume..." && + btrfs subvolume delete "/mnt/@root" + + + echo "restoring blank /root subvolume..." + btrfs subvolume snapshot /mnt/@root-blank /mnt/@root + + echo "deleting /home subvolume..." + btrfs subvolume delete /mnt/@home + + echo "restoring blank /home subvolume..." + btrfs subvolume snapshot /mnt/@home-blank /mnt/@home + + umount /mnt + ''; +}