diff options
-rw-r--r-- | lib/tests/modules/deferred-module.nix | 2 | ||||
-rw-r--r-- | lib/types.nix | 4 | ||||
-rw-r--r-- | nixos/doc/manual/development/option-types.section.md | 5 | ||||
-rw-r--r-- | nixos/doc/manual/from_md/development/option-types.section.xml | 20 |
4 files changed, 19 insertions, 12 deletions
diff --git a/lib/tests/modules/deferred-module.nix b/lib/tests/modules/deferred-module.nix index e963c5a845c1f..d03c60b029bf1 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 68dfa5843dee5..354714b287333 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 0241aae1dc896..e4e6cfec957f6 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 820646be671f4..e3d161e4d3519 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. </para> <para> - Module authors can use its value, which is always a list of - module values, in <literal>imports</literal> or in - <literal>submoduleWith</literal>’s - <literal>modules</literal> parameter. Note that - <literal>imports</literal> must be evaluated before the - module fixpoint. Because of this, deferred modules can only - be imported into <quote>other</quote> fixpoints, such as - submodules. + Module authors can use its value in + <literal>imports</literal>, in + <literal>submoduleWith</literal><quote>s + <literal>modules</literal> or in + <literal>evalModules</literal></quote> + <literal>modules</literal> parameter, among other places. + </para> + <para> + Note that <literal>imports</literal> must be evaluated + before the module fixpoint. Because of this, deferred + modules can only be imported into <quote>other</quote> + fixpoints, such as submodules. </para> <para> One use case for this type is the type of a |