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:
Tim Cuthbertson
2018-10-20 22:33:04 +11:00
parent 7a10601dc4
commit d984c55383
2 changed files with 7 additions and 4 deletions
+6 -3
View File
@@ -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.