From 0d07d230c09e242b721e7298fd3705a64888083c Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Wed, 26 Apr 2023 22:56:43 +0530 Subject: [PATCH] configure nix --- common/nix.nix | 2 ++ hosts/skipper/rollback.nix | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 hosts/skipper/rollback.nix 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 + ''; +}