From cf4da9fd69fc12ab7ca2ba242620fc8d1932d524 Mon Sep 17 00:00:00 2001 From: cinereal Date: Mon, 24 Nov 2025 17:52:28 +0100 Subject: [PATCH] lib/types: make `attrTag`'s `description` field list valid choices Lists the valid choices in `attrTag` type's `description` field. Given this description is used in error messages, this serves to make for somewhat more descriptive errors in the event an option involving this type turns out not to match. Signed-off-by: cinereal --- lib/tests/modules.sh | 12 ++++++------ lib/types.nix | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 505c1c5a5fe4..f2e6d3b452b5 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -200,12 +200,12 @@ checkConfigError '.*A definition for option .bad. is not of type .non-empty .lis # types.attrTag checkConfigOutput '^true$' config.okChecks ./types-attrTag.nix -checkConfigError 'A definition for option .intStrings\.syntaxError. is not of type .attribute-tagged union' config.intStrings.syntaxError ./types-attrTag.nix -checkConfigError 'A definition for option .intStrings\.syntaxError2. is not of type .attribute-tagged union' config.intStrings.syntaxError2 ./types-attrTag.nix -checkConfigError 'A definition for option .intStrings\.syntaxError3. is not of type .attribute-tagged union' config.intStrings.syntaxError3 ./types-attrTag.nix -checkConfigError 'A definition for option .intStrings\.syntaxError4. is not of type .attribute-tagged union' config.intStrings.syntaxError4 ./types-attrTag.nix -checkConfigError 'A definition for option .intStrings\.mergeError. is not of type .attribute-tagged union' config.intStrings.mergeError ./types-attrTag.nix -checkConfigError 'A definition for option .intStrings\.badTagError. is not of type .attribute-tagged union' config.intStrings.badTagError ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError. is not of type .attribute-tagged union with choices: left, right' config.intStrings.syntaxError ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError2. is not of type .attribute-tagged union with choices: left, right' config.intStrings.syntaxError2 ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError3. is not of type .attribute-tagged union with choices: left, right' config.intStrings.syntaxError3 ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.syntaxError4. is not of type .attribute-tagged union with choices: left, right' config.intStrings.syntaxError4 ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.mergeError. is not of type .attribute-tagged union with choices: left, right' config.intStrings.mergeError ./types-attrTag.nix +checkConfigError 'A definition for option .intStrings\.badTagError. is not of type .attribute-tagged union with choices: left, right' config.intStrings.badTagError ./types-attrTag.nix checkConfigError 'A definition for option .intStrings\.badTagTypeError\.left. is not of type .signed integer.' config.intStrings.badTagTypeError.left ./types-attrTag.nix checkConfigError 'A definition for option .nested\.right\.left. is not of type .signed integer.' config.nested.right.left ./types-attrTag.nix checkConfigError 'In attrTag, each tag value must be an option, but tag int was a bare type, not wrapped in mkOption.' config.opt.int ./types-attrTag-wrong-decl.nix diff --git a/lib/types.nix b/lib/types.nix index e57ceafcbaa4..bc6e28ed9363 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -965,7 +965,7 @@ let in mkOptionType { name = "attrTag"; - description = "attribute-tagged union"; + description = "attribute-tagged union with choices: ${choicesStr}"; descriptionClass = "noun"; getSubOptions = prefix: mapAttrs (tagName: tagOption: tagOption // { loc = prefix ++ [ tagName ]; }) tags;