lib/modules: fix error-message when declaring an option inside `config'
The message I originally implemented here was to catch a mixup of
`config' and `options' in a `types.submodule'[1]. However it looks
rather weird for a wrongly declared top-level option.
So I decided to throw
error: The option `foo' does not exist. Definition values:
- In `<unknown-file>':
{
bar = {
_type = "option";
type = {
_type = "option-type";
...
It seems as you're trying to declare an option by placing it into `config' rather than `options'!
for an expression like
with import ./lib;
evalModules {
modules = [
{
foo.bar = mkOption {
type = types.str;
};
}
];
}
[1] fa30c9abed
This commit is contained in:
parent
fbc9084c39
commit
b6d3c9f821
|
@ -162,9 +162,20 @@ rec {
|
||||||
baseMsg = "The option `${showOption (prefix ++ firstDef.prefix)}' does not exist. Definition values:${showDefs [ firstDef ]}";
|
baseMsg = "The option `${showOption (prefix ++ firstDef.prefix)}' does not exist. Definition values:${showDefs [ firstDef ]}";
|
||||||
in
|
in
|
||||||
if attrNames options == [ "_module" ]
|
if attrNames options == [ "_module" ]
|
||||||
|
then
|
||||||
|
let
|
||||||
|
optionName = showOption prefix;
|
||||||
|
in
|
||||||
|
if optionName == ""
|
||||||
then throw ''
|
then throw ''
|
||||||
${baseMsg}
|
${baseMsg}
|
||||||
|
|
||||||
|
It seems as you're trying to declare an option by placing it into `config' rather than `options'!
|
||||||
|
''
|
||||||
|
else
|
||||||
|
throw ''
|
||||||
|
${baseMsg}
|
||||||
|
|
||||||
However there are no options defined in `${showOption prefix}'. Are you sure you've
|
However there are no options defined in `${showOption prefix}'. Are you sure you've
|
||||||
declared your options properly? This can happen if you e.g. declared your options in `types.submodule'
|
declared your options properly? This can happen if you e.g. declared your options in `types.submodule'
|
||||||
under `config' rather than `options'.
|
under `config' rather than `options'.
|
||||||
|
|
Loading…
Reference in a new issue