From d7a109b59f18756fa36a6f6439f11a9eb07e8d86 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Mon, 6 Jan 2020 22:04:14 +0100 Subject: [PATCH] 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. --- lib/types.nix | 3 +-- 1 file changed, 1 insertion(+), 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; };