lib/path: allow CA paths in hasStorePathPrefix (#386774)

authored by Robert Hensing and committed by GitHub 877ebad7 28c0f461

+17 -1
+7 -1
lib/path/default.nix
··· 159 # but this is not fully specified, so let's tie this too much to the currently implemented concept of store paths. 160 # Similar reasoning applies to the validity of the name part. 161 # We care more about discerning store path-ness on realistic values. Making it airtight would be fragile and slow. 162 - && match ".{32}-.+" (elemAt components storeDirLength) != null; 163 164 in 165 # No rec! Add dependencies on this file at the top.
··· 159 # but this is not fully specified, so let's tie this too much to the currently implemented concept of store paths. 160 # Similar reasoning applies to the validity of the name part. 161 # We care more about discerning store path-ness on realistic values. Making it airtight would be fragile and slow. 162 + && match ".{32}-.+" (elemAt components storeDirLength) != null 163 + # alternatively match content‐addressed derivations, which _currently_ do 164 + # not have a store directory prefix. 165 + # This is a workaround for https://github.com/NixOS/nix/issues/12361 which 166 + # was needed during the experimental phase of ca-derivations and should be 167 + # removed once the issue has been resolved. 168 + || match "[0-9a-z]{52}" (head components) != null; 169 170 in 171 # No rec! Add dependencies on this file at the top.
+10
lib/path/tests/unit.nix
··· 137 expected = true; 138 }; 139 140 # Test examples from the lib.path.subpath.isValid documentation 141 testSubpathIsValidExample1 = { 142 expr = subpath.isValid null;
··· 137 expected = true; 138 }; 139 140 + # Test paths for content‐addressed derivations 141 + testHasStorePathPrefixExample7 = { 142 + expr = hasStorePathPrefix (/. + "/1121rp0gvr1qya7hvy925g5kjwg66acz6sn1ra1hca09f1z5dsab"); 143 + expected = true; 144 + }; 145 + testHasStorePathPrefixExample8 = { 146 + expr = hasStorePathPrefix (/. + "/1121rp0gvr1qya7hvy925g5kjwg66acz6sn1ra1hca09f1z5dsab/foo/bar"); 147 + expected = true; 148 + }; 149 + 150 # Test examples from the lib.path.subpath.isValid documentation 151 testSubpathIsValidExample1 = { 152 expr = subpath.isValid null;