1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-21 13:10:33 +00:00

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.
This commit is contained in:
Silvan Mosberger 2020-01-06 22:04:14 +01:00
parent 00c813a636
commit d7a109b59f
No known key found for this signature in database
GPG key ID: E8F1E9EAD284E17D

View file

@ -242,8 +242,7 @@ rec {
path = mkOptionType { path = mkOptionType {
name = "path"; name = "path";
# Hacky: there is no isPath primop. check = x: isCoercibleToString x && builtins.substring 0 1 (toString x) == "/";
check = x: builtins.substring 0 1 (toString x) == "/";
merge = mergeEqualOption; merge = mergeEqualOption;
}; };