lol

Merge pull request #249923 from hercules-ci/modules-catch-bare-type-better

authored by

Silvan Mosberger and committed by
GitHub
a9f3a867 84ffd8ca

+6 -6
+3 -3
lib/modules.nix
··· 633 633 optionDecls = filter 634 634 (m: m.options?_type 635 635 && (m.options._type == "option" 636 - || throwDeclarationTypeError loc m.options._type 636 + || throwDeclarationTypeError loc m.options._type m._file 637 637 ) 638 638 ) 639 639 decls; ··· 698 698 ) unmatchedDefnsByName); 699 699 }; 700 700 701 - throwDeclarationTypeError = loc: actualTag: 701 + throwDeclarationTypeError = loc: actualTag: file: 702 702 let 703 703 name = lib.strings.escapeNixIdentifier (lib.lists.last loc); 704 704 path = showOption loc; 705 705 depth = length loc; 706 706 707 707 paragraphs = [ 708 - "Expected an option declaration at option path `${path}` but got an attribute set with type ${actualTag}" 708 + "In module ${file}: expected an option declaration at option path `${path}` but got an attribute set with type ${actualTag}" 709 709 ] ++ optional (actualTag == "option-type") '' 710 710 When declaring an option, you must wrap the type in a `mkOption` call. It should look somewhat like: 711 711 ${comment}
+3 -3
lib/tests/modules.sh
··· 394 394 ./declare-set.nix ./declare-enable-nested.nix 395 395 396 396 # Options: accidental use of an option-type instead of option (or other tagged type; unlikely) 397 - checkConfigError 'Expected an option declaration at option path .result. but got an attribute set with type option-type' config.result ./options-type-error-typical.nix 398 - checkConfigError 'Expected an option declaration at option path .result.here. but got an attribute set with type option-type' config.result.here ./options-type-error-typical-nested.nix 399 - checkConfigError 'Expected an option declaration at option path .result. but got an attribute set with type configuration' config.result ./options-type-error-configuration.nix 397 + checkConfigError 'In module .*/options-type-error-typical.nix: expected an option declaration at option path .result. but got an attribute set with type option-type' config.result ./options-type-error-typical.nix 398 + checkConfigError 'In module .*/options-type-error-typical-nested.nix: expected an option declaration at option path .result.here. but got an attribute set with type option-type' config.result.here ./options-type-error-typical-nested.nix 399 + checkConfigError 'In module .*/options-type-error-configuration.nix: expected an option declaration at option path .result. but got an attribute set with type configuration' config.result ./options-type-error-configuration.nix 400 400 401 401 # Check that that merging of option collisions doesn't depend on type being set 402 402 checkConfigError 'The option .group..*would be a parent of the following options, but its type .<no description>. does not support nested options.\n\s*- option.s. with prefix .group.enable..*' config.group.enable ./merge-typeless-option.nix