diff options
author | Silvan Mosberger <contact@infinisil.com> | 2020-01-10 16:35:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-10 16:35:25 +0100 |
commit | 5239b328f8796192db8f8516fc5dc2d270c8ab10 (patch) | |
tree | 6c2e33d1695e2e8ee04e528fb72f39bfa17cc6ae /nixos | |
parent | de26ac107f3fdf2e41775040ea65a192a1b5056f (diff) | |
parent | 9e97e6484722e26aab3978d027e85d394f170495 (diff) |
lib/types: Introduce lazyAttrsOf (#70138)
lib/types: Introduce lazyAttrsOf
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/doc/manual/development/option-types.xml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/nixos/doc/manual/development/option-types.xml b/nixos/doc/manual/development/option-types.xml index 1ec7e3efad714..55d9c123e3f11 100644 --- a/nixos/doc/manual/development/option-types.xml +++ b/nixos/doc/manual/development/option-types.xml @@ -352,6 +352,36 @@ An attribute set of where all the values are of <replaceable>t</replaceable> type. Multiple definitions result in the joined attribute set. + <note><para> + This type is <emphasis>strict</emphasis> in its values, which in turn + means attributes cannot depend on other attributes. See <varname> + types.lazyAttrsOf</varname> for a lazy version. + </para></note> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <varname>types.lazyAttrsOf</varname> <replaceable>t</replaceable> + </term> + <listitem> + <para> + An attribute set of where all the values are of + <replaceable>t</replaceable> type. Multiple definitions result in the + joined attribute set. This is the lazy version of <varname>types.attrsOf + </varname>, allowing attributes to depend on each other. + <warning><para> + This version does not fully support conditional definitions! With an + option <varname>foo</varname> of this type and a definition + <literal>foo.attr = lib.mkIf false 10</literal>, evaluating + <literal>foo ? attr</literal> will return <literal>true</literal> + even though it should be false. Accessing the value will then throw + an error. For types <replaceable>t</replaceable> that have an + <literal>emptyValue</literal> defined, that value will be returned + instead of throwing an error. So if the type of <literal>foo.attr</literal> + was <literal>lazyAttrsOf (nullOr int)</literal>, <literal>null</literal> + would be returned instead for the same <literal>mkIf false</literal> definition. + </para></warning> </para> </listitem> </varlistentry> |