Skip to content

Commit 7a07cc0

Browse files
committed
lib/strings: allow CA paths in isStorePath
1 parent 46c7edc commit 7a07cc0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/strings.nix

+7-1
Original file line numberDiff line numberDiff line change
@@ -2434,7 +2434,13 @@ rec {
24342434
if isStringLike x then
24352435
let str = toString x; in
24362436
substring 0 1 str == "/"
2437-
&& dirOf str == storeDir
2437+
&& (dirOf str == storeDir
2438+
# Match content‐addressed derivations, which _currently_ do not have a
2439+
# store directory prefix.
2440+
# This is a workaround for https://github.com/NixOS/nix/issues/12361
2441+
# which was needed during the experimental phase of ca-derivations and
2442+
# should be removed once the issue has been resolved.
2443+
|| builtins.match "/[0-9a-z]{52}" str != null)
24382444
else
24392445
false;
24402446

lib/tests/misc.nix

+10
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ runTests {
537537
expr =
538538
let goodPath =
539539
"${builtins.storeDir}/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11";
540+
goodCAPath = "/1121rp0gvr1qya7hvy925g5kjwg66acz6sn1ra1hca09f1z5dsab";
540541
in {
541542
storePath = isStorePath goodPath;
542543
storePathDerivation = isStorePath (import ../.. { system = "x86_64-linux"; }).hello;
@@ -545,6 +546,12 @@ runTests {
545546
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
546547
asPath = isStorePath (/. + goodPath);
547548
otherPath = isStorePath "/something/else";
549+
550+
caPath = isStorePath goodCAPath;
551+
caPathAppendix = isStorePath
552+
"${goodCAPath}/bin/python";
553+
caAsPath = isStorePath (/. + goodCAPath);
554+
548555
otherVals = {
549556
attrset = isStorePath {};
550557
list = isStorePath [];
@@ -557,6 +564,9 @@ runTests {
557564
storePathAppendix = false;
558565
nonAbsolute = false;
559566
asPath = true;
567+
caPath = true;
568+
caPathAppendix = false;
569+
caAsPath = true;
560570
otherPath = false;
561571
otherVals = {
562572
attrset = false;

0 commit comments

Comments
 (0)