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.
wip/yesman
Tim Cuthbertson 6 years ago
parent 7a10601dc4
commit d984c55383
  1. 9
      lib/strings.nix
  2. 2
      lib/tests/misc.nix

@ -502,9 +502,12 @@ rec {
=> false
*/
isStorePath = x:
isCoercibleToString x
&& builtins.substring 0 1 (toString x) == "/"
&& dirOf x == builtins.storeDir;
if isCoercibleToString x then
let str = toString x; in
builtins.substring 0 1 str == "/"
&& dirOf str == builtins.storeDir
else
false;
/* Convert string to int
Obviously, it is a bit hacky to use fromJSON that way.

@ -112,7 +112,7 @@ runTests {
storePathAppendix = isStorePath
"${goodPath}/bin/python";
nonAbsolute = isStorePath (concatStrings (tail (stringToCharacters goodPath)));
asPath = isStorePath goodPath;
asPath = isStorePath (/. + goodPath);
otherPath = isStorePath "/something/else";
otherVals = {
attrset = isStorePath {};

Loading…
Cancel
Save