lib.isStorePath: fix `false` result when passed a path object
Since `isStorePath` relies on comparing against builtins.storeDir (a string), we need to convert the input into a string as well.
This commit is contained in:
parent
7a10601dc4
commit
d984c55383
|
@ -502,9 +502,12 @@ rec {
|
||||||
=> false
|
=> false
|
||||||
*/
|
*/
|
||||||
isStorePath = x:
|
isStorePath = x:
|
||||||
isCoercibleToString x
|
if isCoercibleToString x then
|
||||||
&& builtins.substring 0 1 (toString x) == "/"
|
let str = toString x; in
|
||||||
&& dirOf x == builtins.storeDir;
|
builtins.substring 0 1 str == "/"
|
||||||
|
&& dirOf str == builtins.storeDir
|
||||||
|
else
|
||||||
|
false;
|
||||||
|
|
||||||
/* Convert string to int
|
/* Convert string to int
|
||||||
Obviously, it is a bit hacky to use fromJSON that way.
|
Obviously, it is a bit hacky to use fromJSON that way.
|
||||||
|
|
|
@ -112,7 +112,7 @@ runTests {
|
||||||
storePathAppendix = isStorePath
|
storePathAppendix = isStorePath
|
||||||
"${goodPath}/bin/python";
|
"${goodPath}/bin/python";
|
||||||
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
|
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
|
||||||
asPath = isStorePath goodPath;
|
asPath = isStorePath (/. + goodPath);
|
||||||
otherPath = isStorePath "/something/else";
|
otherPath = isStorePath "/something/else";
|
||||||
otherVals = {
|
otherVals = {
|
||||||
attrset = isStorePath {};
|
attrset = isStorePath {};
|
||||||
|
|
Loading…
Reference in New Issue