summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2022-06-14 02:12:43 +0200
committerRobert Hensing <robert@roberthensing.nl>2022-06-14 23:01:27 +0200
commitdfd98a5da26c341cf3b7e6fe7e2dbbaeb0af519c (patch)
treef47e1a16304110699fe706dab47cd2f907568be6
parent19a069ab8b17834da249b5ecb507c2eabe76a3e3 (diff)
downloadnixpkgs-dfd98a5da26c341cf3b7e6fe7e2dbbaeb0af519c.tar
nixpkgs-dfd98a5da26c341cf3b7e6fe7e2dbbaeb0af519c.tar.gz
nixpkgs-dfd98a5da26c341cf3b7e6fe7e2dbbaeb0af519c.tar.bz2
nixpkgs-dfd98a5da26c341cf3b7e6fe7e2dbbaeb0af519c.tar.lz
nixpkgs-dfd98a5da26c341cf3b7e6fe7e2dbbaeb0af519c.tar.xz
nixpkgs-dfd98a5da26c341cf3b7e6fe7e2dbbaeb0af519c.tar.zst
nixpkgs-dfd98a5da26c341cf3b7e6fe7e2dbbaeb0af519c.zip
lib.deferredModule: Make it properly singular
-rw-r--r--lib/tests/modules/deferred-module.nix2
-rw-r--r--lib/types.nix4
-rw-r--r--nixos/doc/manual/development/option-types.section.md5
-rw-r--r--nixos/doc/manual/from_md/development/option-types.section.xml20
4 files changed, 19 insertions, 12 deletions
diff --git a/lib/tests/modules/deferred-module.nix b/lib/tests/modules/deferred-module.nix
index e963c5a845c..d03c60b029b 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 68dfa5843de..354714b2873 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 0241aae1dc8..e4e6cfec957 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 820646be671..e3d161e4d35 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