diff --git a/lib/tests/modules/deferred-module.nix b/lib/tests/modules/deferred-module.nix
index e963c5a845c1..d03c60b029bf 100644
--- a/lib/tests/modules/deferred-module.nix
+++ b/lib/tests/modules/deferred-module.nix
@@ -12,7 +12,7 @@ in
({ config, ... }: {
_file = "generic.nix";
options.nodes = mkOption {
- type = lazyAttrsOf (submodule { imports = config.default; });
+ type = lazyAttrsOf (submodule { imports = [ config.default ]; });
default = {};
};
options.default = mkOption {
diff --git a/lib/types.nix b/lib/types.nix
index 68dfa5843dee..354714b28733 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -549,7 +549,9 @@ rec {
name = "deferredModule";
description = "module";
check = x: isAttrs x || isFunction x || path.check x;
- merge = loc: defs: staticModules ++ map (def: lib.setDefaultModuleLocation "${def.file}, via option ${showOption loc}" def.value) defs;
+ merge = loc: defs: {
+ imports = staticModules ++ map (def: lib.setDefaultModuleLocation "${def.file}, via option ${showOption loc}" def.value) defs;
+ };
inherit (submoduleWith { modules = staticModules; })
getSubOptions
getSubModules;
diff --git a/nixos/doc/manual/development/option-types.section.md b/nixos/doc/manual/development/option-types.section.md
index 0241aae1dc89..e4e6cfec957f 100644
--- a/nixos/doc/manual/development/option-types.section.md
+++ b/nixos/doc/manual/development/option-types.section.md
@@ -227,8 +227,9 @@ Value types are types that take a value parameter.
It can be set multiple times.
- Module authors can use its value, which is always a list of module values,
- in `imports` or in `submoduleWith`'s `modules` parameter.
+ Module authors can use its value in `imports`, in `submoduleWith`'s `modules`
+ or in `evalModules`' `modules` parameter, among other places.
+
Note that `imports` must be evaluated before the module fixpoint. Because
of this, deferred modules can only be imported into "other" fixpoints, such
as submodules.
diff --git a/nixos/doc/manual/from_md/development/option-types.section.xml b/nixos/doc/manual/from_md/development/option-types.section.xml
index 820646be671f..e3d161e4d351 100644
--- a/nixos/doc/manual/from_md/development/option-types.section.xml
+++ b/nixos/doc/manual/from_md/development/option-types.section.xml
@@ -441,14 +441,18 @@
It can be set multiple times.
- Module authors can use its value, which is always a list of
- module values, in imports or in
- submoduleWith’s
- modules parameter. Note that
- imports must be evaluated before the
- module fixpoint. Because of this, deferred modules can only
- be imported into other
fixpoints, such as
- submodules.
+ Module authors can use its value in
+ imports, in
+ submoduleWiths
+ modules or in
+ evalModules
+ modules parameter, among other places.
+
+
+ Note that imports must be evaluated
+ before the module fixpoint. Because of this, deferred
+ modules can only be imported into other
+ fixpoints, such as submodules.
One use case for this type is the type of a