diff options
author | Robert Hensing <robert@roberthensing.nl> | 2022-03-10 22:45:41 +0100 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2022-06-14 23:01:23 +0200 |
commit | 4746f6d03e4f8dc6e7399f45aaba0ca3aac32761 (patch) | |
tree | 454bacc3665fb4f41f6f06322dd799367403ebb3 /nixos/doc/manual | |
parent | 9ef09e06806e79e32e30d17aee6879d69c011037 (diff) |
lib.types: Add deferredModule
Diffstat (limited to 'nixos/doc/manual')
-rw-r--r-- | nixos/doc/manual/development/option-types.section.md | 19 | ||||
-rw-r--r-- | nixos/doc/manual/from_md/development/option-types.section.xml | 34 |
2 files changed, 53 insertions, 0 deletions
diff --git a/nixos/doc/manual/development/option-types.section.md b/nixos/doc/manual/development/option-types.section.md index d32d4fc50ad79..0241aae1dc896 100644 --- a/nixos/doc/manual/development/option-types.section.md +++ b/nixos/doc/manual/development/option-types.section.md @@ -220,6 +220,25 @@ Value types are types that take a value parameter. requires using a function: `the-submodule = { ... }: { options = { ... }; }`. +`types.deferredModule` + +: Whereas `submodule` represents an option tree, `deferredModule` represents + a module value, such as a module file or a configuration. + + 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. + + One use case for this type is the type of a "default" module that allow the + user to affect all submodules in an `attrsOf submodule` at once. This is + more convenient and discoverable than expecting the module user to + type-merge with the `attrsOf submodule` option. NixOps uses this type in + `network.defaults`. + ## Composed Types {#sec-option-types-composed} Composed types are types that take a type as parameter. `listOf 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 c67e183581c2c..820646be671f4 100644 --- a/nixos/doc/manual/from_md/development/option-types.section.xml +++ b/nixos/doc/manual/from_md/development/option-types.section.xml @@ -427,6 +427,40 @@ </itemizedlist> </listitem> </varlistentry> + <varlistentry> + <term> + <literal>types.deferredModule</literal> + </term> + <listitem> + <para> + Whereas <literal>submodule</literal> represents an option + tree, <literal>deferredModule</literal> represents a module + value, such as a module file or a configuration. + </para> + <para> + 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. + </para> + <para> + One use case for this type is the type of a + <quote>default</quote> module that allow the user to affect + all submodules in an <literal>attrsOf submodule</literal> at + once. This is more convenient and discoverable than + expecting the module user to type-merge with the + <literal>attrsOf submodule</literal> option. NixOps uses + this type in <literal>network.defaults</literal>. + </para> + </listitem> + </varlistentry> </variablelist> </section> <section xml:id="sec-option-types-composed"> |