diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 72ca379f40df3..d8a041cf26498 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -173,6 +173,7 @@ checkConfigOutput '^"one two"$' config.result ./shorthand-meta.nix checkConfigError "In module .*test-push-down-non-attrs.nix., you're trying to define a value of type \`bool'\n\s*rather than an attribute set for the option" config ./test-push-down-non-attrs.nix checkConfigError "In module .*test-push-down-non-attrs-nested.nix., you're trying to define a value of type \`bool'\n\s*rather than an attribute set for the option\n\s*\`a\.b'!" config.a.b.c ./test-push-down-non-attrs-nested.nix +checkConfigOutput '^1$' config.a.b.x ./options-lazy-in-unmatched-defns.nix checkConfigOutput '^true$' config.result ./test-mergeAttrDefinitionsWithPrio.nix checkConfigOutput '^true$' config.result ./test-fixupOptionType-idempotent.nix diff --git a/lib/tests/modules/options-lazy-in-unmatched-defns.nix b/lib/tests/modules/options-lazy-in-unmatched-defns.nix new file mode 100644 index 0000000000000..b4c288c40e96d --- /dev/null +++ b/lib/tests/modules/options-lazy-in-unmatched-defns.nix @@ -0,0 +1,12 @@ +{ lib, options, ... }: + +{ + options.a.b = lib.mkOption { + type = lib.types.attrs; + default = { }; + }; + + # Reading a nested option's declarations must not require the definitions + # under its parent, e.g. to check them for unmatched definitions. + config.a = if options.a.b.declarations != [ ] then { b.x = 1; } else { }; +}