diff options
author | Robert Hensing <robert@roberthensing.nl> | 2022-04-24 00:07:59 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2022-04-24 00:07:59 +0200 |
commit | 224426ba6d4370ede958c127d9b9866a189522f9 (patch) | |
tree | 6c7acf114ed5e73c23ff114c41f60a5395942476 /lib/tests | |
parent | 3ca4a1714a8990158dd69ca557248b121cbdc973 (diff) |
lib.types.submoduleWith: Avoid _key collisions after extendModules
Diffstat (limited to 'lib/tests')
-rwxr-xr-x | lib/tests/modules.sh | 6 | ||||
-rw-r--r-- | lib/tests/modules/extendModules-168767-imports.nix | 41 |
2 files changed, 46 insertions, 1 deletions
diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 8050c6539fc20..cc13a8d38e375 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -293,7 +293,7 @@ checkConfigOutput '^"a c"$' config.result ./functionTo/merging-attrs.nix # moduleType checkConfigOutput '^"a b"$' config.resultFoo ./declare-variants.nix ./define-variant.nix -checkConfigOutput '^"a y z"$' config.resultFooBar ./declare-variants.nix ./define-variant.nix +checkConfigOutput '^"a b y z"$' config.resultFooBar ./declare-variants.nix ./define-variant.nix checkConfigOutput '^"a b c"$' config.resultFooFoo ./declare-variants.nix ./define-variant.nix ## emptyValue's @@ -327,6 +327,10 @@ checkConfigError 'The option .theOption.nested. in .other.nix. is already declar # Test that types.optionType leaves types untouched as long as they don't need to be merged checkConfigOutput 'ok' config.freeformItems.foo.bar ./adhoc-freeformType-survives-type-merge.nix +# Anonymous submodules don't get nixed by import resolution/deduplication +# because of an `extendModules` bug, issue 168767. +checkConfigOutput '^1$' config.sub.specialisation.value ./extendModules-168767-imports.nix + cat <<EOF ====== module tests ====== $pass Pass diff --git a/lib/tests/modules/extendModules-168767-imports.nix b/lib/tests/modules/extendModules-168767-imports.nix new file mode 100644 index 0000000000000..489e6b5a5d836 --- /dev/null +++ b/lib/tests/modules/extendModules-168767-imports.nix @@ -0,0 +1,41 @@ +{ lib +, extendModules +, ... +}: +with lib; +{ + imports = [ + + { + options.sub = mkOption { + default = { }; + type = types.submodule ( + { config + , extendModules + , ... + }: + { + options.value = mkOption { + type = types.int; + }; + + options.specialisation = mkOption { + default = { }; + inherit + (extendModules { + modules = [{ + specialisation = mkOverride 0 { }; + }]; + }) + type; + }; + } + ); + }; + } + + { config.sub.value = 1; } + + + ]; +} |