From cf5a46368bfdef67223de8206c01370b106e12ab Mon Sep 17 00:00:00 2001 From: HexoKnight Date: Tue, 10 Sep 2024 22:45:27 +0100 Subject: [PATCH] lib/types: fix toCoerced's typeMerge --- lib/tests/modules.sh | 3 +++ lib/tests/modules/declare-coerced-value-no-default.nix | 9 +++++++++ lib/types.nix | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 lib/tests/modules/declare-coerced-value-no-default.nix diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index a14fe8cb30a54..2a48d88cbf732 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -294,6 +294,9 @@ checkConfigOutput '^"42"$' config.value ./declare-coerced-value.nix checkConfigOutput '^"24"$' config.value ./declare-coerced-value.nix ./define-value-string.nix checkConfigError 'A definition for option .* is not.*string or signed integer convertible to it.*. Definition values:\n\s*- In .*: \[ \]' config.value ./declare-coerced-value.nix ./define-value-list.nix +# Check coerced option merging. +checkConfigError 'The option .value. in .*/declare-coerced-value.nix. is already declared in .*/declare-coerced-value-no-default.nix.' config.value ./declare-coerced-value.nix ./declare-coerced-value-no-default.nix + # Check coerced value with unsound coercion checkConfigOutput '^12$' config.value ./declare-coerced-value-unsound.nix checkConfigError 'A definition for option .* is not of type .*. Definition values:\n\s*- In .*: "1000"' config.value ./declare-coerced-value-unsound.nix ./define-value-string-bigint.nix diff --git a/lib/tests/modules/declare-coerced-value-no-default.nix b/lib/tests/modules/declare-coerced-value-no-default.nix new file mode 100644 index 0000000000000..820913f920c35 --- /dev/null +++ b/lib/tests/modules/declare-coerced-value-no-default.nix @@ -0,0 +1,9 @@ +{ lib, ... }: + +{ + options = { + value = lib.mkOption { + type = lib.types.coercedTo lib.types.int builtins.toString lib.types.str; + }; + }; +} diff --git a/lib/types.nix b/lib/types.nix index 8b1d19ff2c613..86b717afd1227 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -1035,7 +1035,7 @@ rec { getSubOptions = finalType.getSubOptions; getSubModules = finalType.getSubModules; substSubModules = m: coercedTo coercedType coerceFunc (finalType.substSubModules m); - typeMerge = t1: t2: null; + typeMerge = t: null; functor = (defaultFunctor name) // { wrapped = finalType; }; nestedTypes.coercedType = coercedType; nestedTypes.finalType = finalType;