diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 9b1348f58c9c..155d7e5fa3d2 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -194,8 +194,11 @@ checkConfigOutput '^"submodule"$' options.submodule.type.description ./declare-s ## Paths should be allowed as values and work as expected checkConfigOutput '^true$' config.submodule.enable ./declare-submoduleWith-path.nix -## Deferred module +## deferredModule +# default module is merged into nodes.foo checkConfigOutput '"beta"' config.nodes.foo.settingsDict.c ./deferred-module.nix +# errors from the default module are reported with accurate location +checkConfigError 'In `default from the-file-that-contains-the-bad-config.nix'\'': "bogus"' config.nodes.foo.bottom ./deferred-module.nix # Check the file location information is propagated into submodules checkConfigOutput the-file.nix config.submodule.internalFiles.0 ./submoduleFiles.nix diff --git a/lib/tests/modules/deferred-module.nix b/lib/tests/modules/deferred-module.nix index faf459a991fa..dc8072d4e6c3 100644 --- a/lib/tests/modules/deferred-module.nix +++ b/lib/tests/modules/deferred-module.nix @@ -1,7 +1,7 @@ { lib, ... }: let inherit (lib) types mkOption setDefaultModuleLocation; - inherit (types) deferredModule lazyAttrsOf submodule str raw; + inherit (types) deferredModule lazyAttrsOf submodule str raw enum; in { imports = [ @@ -28,6 +28,7 @@ in _file = "default-1.nix"; default = { config, ... }: { options.settingsDict = lib.mkOption { type = lazyAttrsOf str; default = {}; }; + options.bottom = lib.mkOption { type = enum []; }; }; } @@ -43,6 +44,11 @@ in nodes.foo.settingsDict.b = "beta"; } + { + _file = "the-file-that-contains-the-bad-config.nix"; + default.bottom = "bogus"; + } + { _file = "nodes-foo-c-is-a.nix"; nodes.foo = { config, ... }: {