lib/tests/modules: make sure options stay lazy in unmatched definitions

This commit is contained in:
Philip Taron
2026-11-05 17:33:55 -08:00
parent 8be36b7986
commit 4e47504aac
2 changed files with 13 additions and 0 deletions

View File

@@ -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

View File

@@ -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 { };
}