lib/modules: Test optionless module errors from #131205
This commit is contained in:
@@ -275,6 +275,8 @@ let
|
|||||||
"The option `${optText}' does not exist. Definition values:${defText}";
|
"The option `${optText}' does not exist. Definition values:${defText}";
|
||||||
in
|
in
|
||||||
if attrNames options == [ "_module" ]
|
if attrNames options == [ "_module" ]
|
||||||
|
# No options were declared at all (`_module` is built in)
|
||||||
|
# but we do have unmatched definitions, and no freeformType (earlier conditions)
|
||||||
then
|
then
|
||||||
let
|
let
|
||||||
optionName = showOption prefix;
|
optionName = showOption prefix;
|
||||||
|
|||||||
@@ -94,6 +94,11 @@ checkConfigOutput '^true$' config.result ./module-argument-default.nix
|
|||||||
# gvariant
|
# gvariant
|
||||||
checkConfigOutput '^true$' config.assertion ./gvariant.nix
|
checkConfigOutput '^true$' config.assertion ./gvariant.nix
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/pull/131205
|
||||||
|
checkConfigError 'It seems as if you.re trying to declare an option by placing it into .config. rather than .options.' config.wrong1 ./error-mkOption-in-config.nix
|
||||||
|
checkConfigError 'The option .sub.wrong2. does not exist. Definition values:' config.sub ./error-mkOption-in-submodule-config.nix
|
||||||
|
checkConfigError '.*This can happen if you e.g. declared your options in .types.submodule.' config.sub ./error-mkOption-in-submodule-config.nix
|
||||||
|
|
||||||
# types.pathInStore
|
# types.pathInStore
|
||||||
checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix
|
checkConfigOutput '".*/store/0lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv"' config.pathInStore.ok1 ./types.nix
|
||||||
checkConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathInStore.ok2 ./types.nix
|
checkConfigOutput '".*/store/0fb3ykw9r5hpayd05sr0cizwadzq1d8q-bash-5.2-p15"' config.pathInStore.ok2 ./types.nix
|
||||||
|
|||||||
14
lib/tests/modules/error-mkOption-in-config.nix
Normal file
14
lib/tests/modules/error-mkOption-in-config.nix
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkOption;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
wrong1 = mkOption {
|
||||||
|
};
|
||||||
|
# This is not actually reported separately, so could be omitted from the test
|
||||||
|
# but it makes the example more realistic.
|
||||||
|
# Making it parse this _config_ as options would too risky. What if it's not
|
||||||
|
# options but other values, that abort, throw, diverge, etc?
|
||||||
|
nest.wrong2 = mkOption {
|
||||||
|
};
|
||||||
|
}
|
||||||
12
lib/tests/modules/error-mkOption-in-submodule-config.nix
Normal file
12
lib/tests/modules/error-mkOption-in-submodule-config.nix
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) mkOption;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.sub = lib.mkOption {
|
||||||
|
type = lib.types.submodule {
|
||||||
|
wrong2 = mkOption {};
|
||||||
|
};
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user