aboutsummaryrefslogtreecommitdiff
path: root/lib/strings.nix
diff options
context:
space:
mode:
authorTim Cuthbertson <tim@gfxmonk.net>2018-10-20 22:23:58 +1100
committerTim Cuthbertson <tim@gfxmonk.net>2018-10-20 22:33:04 +1100
commitd984c553832fad99ee48e512252c0f2f27632789 (patch)
tree17911c8be24d3a1a0d5eeb53ff90f9e1273e0ad5 /lib/strings.nix
parent7a10601dc4f818ecc24097ac8ab38e2e0050cf1d (diff)
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.
Diffstat (limited to 'lib/strings.nix')
-rw-r--r--lib/strings.nix9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/strings.nix b/lib/strings.nix
index 0c4095bb55cd..99399459bb48 100644
--- a/lib/strings.nix
+++ b/lib/strings.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.