diff options
author | Shea Levy <shea@shealevy.com> | 2018-03-09 17:21:12 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2018-03-09 17:21:31 -0500 |
commit | b66d7dc0ce684197181a2a8ec0859470137507aa (patch) | |
tree | 5c2f9e4eb8f750dc7f6611ac8d30fe9da06bdd90 /lib/strings.nix | |
parent | d3570a1e219b6aad2447e5e4eb4830369637ce55 (diff) | |
download | nixlib-b66d7dc0ce684197181a2a8ec0859470137507aa.tar nixlib-b66d7dc0ce684197181a2a8ec0859470137507aa.tar.gz nixlib-b66d7dc0ce684197181a2a8ec0859470137507aa.tar.bz2 nixlib-b66d7dc0ce684197181a2a8ec0859470137507aa.tar.lz nixlib-b66d7dc0ce684197181a2a8ec0859470137507aa.tar.xz nixlib-b66d7dc0ce684197181a2a8ec0859470137507aa.tar.zst nixlib-b66d7dc0ce684197181a2a8ec0859470137507aa.zip |
lib.isStorePath: Fix derivation detection
Diffstat (limited to 'lib/strings.nix')
-rw-r--r-- | lib/strings.nix | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/strings.nix b/lib/strings.nix index 9cbd1494a2b5..e6df7d99cb2e 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -437,6 +437,13 @@ rec { */ fixedWidthNumber = width: n: fixedWidthString width "0" (toString n); + /* Check whether a value can be coerced to a string */ + isCoercibleToString = x: + builtins.elem (builtins.typeOf x) [ "path" "string" "null" "int" "float" "bool" ] || + (builtins.isList x && lib.all isCoercibleToString x) || + x ? outPath || + x ? __toString; + /* Check whether a value is a store path. Example: @@ -450,7 +457,7 @@ rec { => false */ isStorePath = x: - builtins.isString x + isCoercibleToString x && builtins.substring 0 1 (toString x) == "/" && dirOf (builtins.toPath x) == builtins.storeDir; |