diff options
author | Silvan Mosberger <infinisil@icloud.com> | 2019-10-12 21:18:53 +0200 |
---|---|---|
committer | Silvan Mosberger <contact@infinisil.com> | 2020-01-10 16:19:55 +0100 |
commit | b48717d1eb9d4d9d60f3460274e7d9a961a402df (patch) | |
tree | 963ddca03bc11d61026ed701c521aa2633c65f63 /nixos | |
parent | 4268b4f9cffc46482ece4a8e0128b8ef09ea6db2 (diff) | |
download | nixpkgs-b48717d1eb9d4d9d60f3460274e7d9a961a402df.tar nixpkgs-b48717d1eb9d4d9d60f3460274e7d9a961a402df.tar.gz nixpkgs-b48717d1eb9d4d9d60f3460274e7d9a961a402df.tar.bz2 nixpkgs-b48717d1eb9d4d9d60f3460274e7d9a961a402df.tar.lz nixpkgs-b48717d1eb9d4d9d60f3460274e7d9a961a402df.tar.xz nixpkgs-b48717d1eb9d4d9d60f3460274e7d9a961a402df.tar.zst nixpkgs-b48717d1eb9d4d9d60f3460274e7d9a961a402df.zip |
lib/types: Introduce lazyAttrsOf
The standard attrsOf is strict in its *values*, meaning it's impossible to access only one attribute value without evaluating all others as well. lazyAttrsOf is a version that doesn't have that problem, at the expense of conditional definitions not properly working anymore.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/doc/manual/development/option-types.xml | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/nixos/doc/manual/development/option-types.xml b/nixos/doc/manual/development/option-types.xml index e4f8396a4bd..55d9c123e3f 100644 --- a/nixos/doc/manual/development/option-types.xml +++ b/nixos/doc/manual/development/option-types.xml @@ -362,6 +362,31 @@ </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> + <varlistentry> + <term> <varname>types.loaOf</varname> <replaceable>t</replaceable> </term> <listitem> |