mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
lib/modules: Report a better error when option tree has bare type
Improves on 0d472a6201
- https://github.com/NixOS/nixpkgs/pull/242339
We actually do have the file name.
Thanks Shawn8901 for the [feedback]!
feedback: https://github.com/NixOS/nixpkgs/pull/242339#issuecomment-1683107055
This commit is contained in:
parent
ed9af6d93e
commit
5ad01f1b6f
|
@ -633,7 +633,7 @@ let
|
|||
optionDecls = filter
|
||||
(m: m.options?_type
|
||||
&& (m.options._type == "option"
|
||||
|| throwDeclarationTypeError loc m.options._type
|
||||
|| throwDeclarationTypeError loc m.options._type m._file
|
||||
)
|
||||
)
|
||||
decls;
|
||||
|
@ -698,14 +698,14 @@ let
|
|||
) unmatchedDefnsByName);
|
||||
};
|
||||
|
||||
throwDeclarationTypeError = loc: actualTag:
|
||||
throwDeclarationTypeError = loc: actualTag: file:
|
||||
let
|
||||
name = lib.strings.escapeNixIdentifier (lib.lists.last loc);
|
||||
path = showOption loc;
|
||||
depth = length loc;
|
||||
|
||||
paragraphs = [
|
||||
"Expected an option declaration at option path `${path}` but got an attribute set with type ${actualTag}"
|
||||
"In module ${file}: expected an option declaration at option path `${path}` but got an attribute set with type ${actualTag}"
|
||||
] ++ optional (actualTag == "option-type") ''
|
||||
When declaring an option, you must wrap the type in a `mkOption` call. It should look somewhat like:
|
||||
${comment}
|
||||
|
|
|
@ -394,9 +394,9 @@ checkConfigError \
|
|||
./declare-set.nix ./declare-enable-nested.nix
|
||||
|
||||
# Options: accidental use of an option-type instead of option (or other tagged type; unlikely)
|
||||
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
|
||||
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
|
||||
checkConfigError 'Expected an option declaration at option path .result. but got an attribute set with type configuration' config.result ./options-type-error-configuration.nix
|
||||
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
|
||||
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
|
||||
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
|
||||
|
||||
# Check that that merging of option collisions doesn't depend on type being set
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue