summary refs log tree commit diff
path: root/lib/types.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <infinisil@icloud.com>2018-03-09 13:41:55 +0100
committerProfpatsch <mail@profpatsch.de>2018-05-06 23:58:36 +0200
commitef8996f15ea2dd5aace0f61f9ab03f3dfa3d4975 (patch)
tree746af10a518ac39134299be845bb5a205cd4a30c /lib/types.nix
parent85b5fc7c9854d5b147fca2399d8ca6c3412afa2f (diff)
downloadnixpkgs-ef8996f15ea2dd5aace0f61f9ab03f3dfa3d4975.tar
nixpkgs-ef8996f15ea2dd5aace0f61f9ab03f3dfa3d4975.tar.gz
nixpkgs-ef8996f15ea2dd5aace0f61f9ab03f3dfa3d4975.tar.bz2
nixpkgs-ef8996f15ea2dd5aace0f61f9ab03f3dfa3d4975.tar.lz
nixpkgs-ef8996f15ea2dd5aace0f61f9ab03f3dfa3d4975.tar.xz
nixpkgs-ef8996f15ea2dd5aace0f61f9ab03f3dfa3d4975.tar.zst
nixpkgs-ef8996f15ea2dd5aace0f61f9ab03f3dfa3d4975.zip
lib/types: Fix coercedTo check
Without this change

  (coercedTo str toInt int).check "foo"

would evaluate to true, even though

  (coercedTo str toInt int).merge {} [{ value = "foo"; }]

will throw an error because "foo" can't be coerced to an int.
Diffstat (limited to 'lib/types.nix')
-rw-r--r--lib/types.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/types.nix b/lib/types.nix
index a334db5c724..45b0ae5042c 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -420,7 +420,7 @@ rec {
       mkOptionType rec {
         name = "coercedTo";
         description = "${finalType.description} or ${coercedType.description}";
-        check = x: finalType.check x || coercedType.check x;
+        check = x: finalType.check x || (coercedType.check x && finalType.check (coerceFunc x));
         merge = loc: defs:
           let
             coerceVal = val: