]> git.scottworley.com Git - nix-profile-gc/commitdiff
Fix profile comparison: Don't use full path where name is expected
authorScott Worley <scottworley@scottworley.com>
Fri, 9 Feb 2024 01:26:05 +0000 (17:26 -0800)
committerScott Worley <scottworley@scottworley.com>
Fri, 9 Feb 2024 01:33:36 +0000 (17:33 -0800)
Bug: Yikes!  This deleted the current profile on a machine that hadn't
been started in awhile.  :(

modules/profile-gc.nix

index 5444798568249e38724cb965ea3068d0747d2afd..3a2e44a153975ea26ddf605a3a7a90e0fc7253d4 100644 (file)
@@ -179,7 +179,8 @@ in {
             echo "(Disregarding unrelated profile $p)" >&2
             continue
           fi
             echo "(Disregarding unrelated profile $p)" >&2
             continue
           fi
-          if [[ "$p" == "$current" ]];then
+          pname=$(${pkgs.coreutils}/bin/basename "$p")
+          if [[ "$pname" == "$current" ]];then
             echo "Keeeping current profile $p" >&2
             continue
           fi
             echo "Keeeping current profile $p" >&2
             continue
           fi
@@ -187,7 +188,7 @@ in {
             echo "Keeeping active system/boot profile $p" >&2
             continue
           fi
             echo "Keeeping active system/boot profile $p" >&2
             continue
           fi
-          if [[ "''${active[$p]:-}" ]];then
+          if [[ "''${active[$pname]:-}" ]];then
             echo "Keeeping active profile $p" >&2
             continue
           fi
             echo "Keeeping active profile $p" >&2
             continue
           fi