aboutsummaryrefslogtreecommitdiff
path: root/tests/modules/deferred-module.nix
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modules/deferred-module.nix')
-rw-r--r--tests/modules/deferred-module.nix58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/modules/deferred-module.nix b/tests/modules/deferred-module.nix
new file mode 100644
index 000000000..d03c60b02
--- /dev/null
+++ b/tests/modules/deferred-module.nix
@@ -0,0 +1,58 @@
+{ lib, ... }:
+let
+ inherit (lib) types mkOption setDefaultModuleLocation;
+ inherit (types) deferredModule lazyAttrsOf submodule str raw enum;
+in
+{
+ imports = [
+ # generic module, declaring submodules:
+ # - nodes.<name>
+ # - default
+ # where all nodes include the default
+ ({ config, ... }: {
+ _file = "generic.nix";
+ options.nodes = mkOption {
+ type = lazyAttrsOf (submodule { imports = [ config.default ]; });
+ default = {};
+ };
+ options.default = mkOption {
+ type = deferredModule;
+ default = { };
+ description = ''
+ Module that is included in all nodes.
+ '';
+ };
+ })
+
+ {
+ _file = "default-1.nix";
+ default = { config, ... }: {
+ options.settingsDict = lib.mkOption { type = lazyAttrsOf str; default = {}; };
+ options.bottom = lib.mkOption { type = enum []; };
+ };
+ }
+
+ {
+ _file = "default-a-is-b.nix";
+ default = ./define-settingsDict-a-is-b.nix;
+ }
+
+ {
+ _file = "nodes-foo.nix";
+ 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, ... }: {
+ settingsDict.c = config.settingsDict.a;
+ };
+ }
+
+ ];
+}