summaryrefslogtreecommitdiff
path: root/lib/path
diff options
context:
space:
mode:
authorMikael Voss <mvs@nyantec.com>2025-03-13 12:57:06 +0100
committerMikael Voss <mvs@nyantec.com>2025-04-02 13:26:43 +0200
commitbf790d1a7fffcfd5c6a92711179d644119128a61 (patch)
tree18969afd6d67392a3dd18a0bc57bd9a97cb55dc7 /lib/path
parentpolkadot: 2412-3 -> 2412-4 (#395145) (diff)
downloadnixpkgs-bf790d1a7fffcfd5c6a92711179d644119128a61.tar.gz
lib/path: properly handle /. in hasStorePathPrefix
Diffstat (limited to 'lib/path')
-rw-r--r--lib/path/default.nix2
-rw-r--r--lib/path/tests/unit.nix6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/path/default.nix b/lib/path/default.nix
index be559eadf182..1284bed94bb0 100644
--- a/lib/path/default.nix
+++ b/lib/path/default.nix
@@ -165,7 +165,7 @@ let
# This is a workaround for https://github.com/NixOS/nix/issues/12361 which
# was needed during the experimental phase of ca-derivations and should be
# removed once the issue has been resolved.
- || match "[0-9a-z]{52}" (head components) != null;
+ || components != [ ] && match "[0-9a-z]{52}" (head components) != null;
in
# No rec! Add dependencies on this file at the top.
diff --git a/lib/path/tests/unit.nix b/lib/path/tests/unit.nix
index a52b4f44e51d..fa2e004e9c3a 100644
--- a/lib/path/tests/unit.nix
+++ b/lib/path/tests/unit.nix
@@ -110,6 +110,12 @@ let
expected = false;
};
+ # Root path (empty path components list)
+ testHasStorePathPrefixRoot = {
+ expr = hasStorePathPrefix /.;
+ expected = false;
+ };
+
testHasStorePathPrefixExample1 = {
expr = hasStorePathPrefix (storeDirPath + "/nvl9ic0pj1fpyln3zaqrf4cclbqdfn1j-foo/bar/baz");
expected = true;