]> git.scottworley.com Git - nix-profile-gc/blobdiff - modules/profile-gc.nix
Fix profile comparison: Don't use full path where name is expected
[nix-profile-gc] / modules / profile-gc.nix
index 1452e8f22e06fa98166c41b0c1da921c437f80ce..3a2e44a153975ea26ddf605a3a7a90e0fc7253d4 100644 (file)
@@ -1,3 +1,18 @@
+# nix-profile-gc: More gently remove old profiles
+# Copyright (C) 2022 Scott Worley <scottworley@scottworley.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
 { lib, config, pkgs, ... }:
 let
   inherit (lib) escapeShellArg;
 { lib, config, pkgs, ... }:
 let
   inherit (lib) escapeShellArg;
@@ -164,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
@@ -172,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