Skip to content

Commit

Permalink
lib/types: Fix path type check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
infinisil committed Jan 6, 2020
1 parent 00c813a commit d7a109b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit d7a109b

Please sign in to comment.