From f59ae5dc715b0e46baa37ffa2784d28457c60bce Mon Sep 17 00:00:00 2001 From: magic_rb Date: Sat, 7 Oct 2023 22:43:51 +0200 Subject: [PATCH] Make use of `rolling_datasets` on omen Signed-off-by: magic_rb --- nixos/systems/omen/impermenance.nix | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/nixos/systems/omen/impermenance.nix b/nixos/systems/omen/impermenance.nix index 6725d9f..b806093 100644 --- a/nixos/systems/omen/impermenance.nix +++ b/nixos/systems/omen/impermenance.nix @@ -81,22 +81,7 @@ unitConfig.DefaultDependencies = "no"; serviceConfig.Type = "oneshot"; script = '' - generation="$(zfs get :generation omen-ssd/ephemeral/home -H -o value)" - dataset="omen-ssd/ephemeral/home" - generation="$(("$generation" + 1))" - zfs set ":generation=$generation" "$dataset" - zfs send "$dataset" | zfs recv "$dataset/$generation" - zfs rollback "$dataset@blank" && echo "rollback complete" - - - while IFS="\n" read gen - do - echo "$gen < $(("$generation" - 10))" - if [ "$gen" -lt "$(("$generation" - 10))" ]; then - zfs destroy -r "$dataset/$gen" - echo "destroyed " - fi - done <<< "$(zfs list "omen-ssd/ephemeral/home" -t filesystem -r -H -o name | xargs -I {} ${pkgs.runtimeShell} -c 'echo "$1" | rev | cut -f 1 -d "/" | rev' sh {} | grep -v home)" + ${pkgs.rolling_datasets}/bin/roll_dataset "omen-ssd/ephemeral/home" "10" ''; };