diff options
author | Silvan Mosberger <contact@infinisil.com> | 2020-01-06 22:04:14 +0100 |
---|---|---|
committer | Silvan Mosberger <contact@infinisil.com> | 2020-01-06 22:09:56 +0100 |
commit | d7a109b59f18756fa36a6f6439f11a9eb07e8d86 (patch) | |
tree | 70e2b7ed3265c7dc3bb65c7553554ceecb5243ab /lib/types.nix | |
parent | 00c813a63628a6bbc315f08687c55a5fb5fa1c91 (diff) |
lib/types: Fix path type check
Previously when this function was called without a value coercible to a
string it would throw an error instead of returning false. Now it does.
As a result this now allows the use of a type like `either path attrs`
without it erroring out when a definition is an attribute set.
The warning about there not being a isPath primop was removed because
this is not the case anymore, there is builtins.isPath. But also there
always was `builtins.typeOf x == "path"` that could've been used
instead. However the path type now stands for more than just path types,
but absolute paths in general.
Diffstat (limited to 'lib/types.nix')
-rw-r--r-- | lib/types.nix | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/types.nix b/lib/types.nix index de3c4f0d6030..d177dda41245 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -242,8 +242,7 @@ rec { path = mkOptionType { name = "path"; - # Hacky: there is no ‘isPath’ primop. - check = x: builtins.substring 0 1 (toString x) == "/"; + check = x: isCoercibleToString x && builtins.substring 0 1 (toString x) == "/"; merge = mergeEqualOption; }; |