query
On this page

lazyAttrsOf

lib.types.lazyAttrsOf

Docs pulled from | This Revision | 18 minutes ago


Nixpkgs manual

types.lazyAttrsOf t

An attribute set of where all the values are of t type. Multiple definitions result in the joined attribute set. This is the lazy version of types.attrsOf , allowing attributes to depend on each other.

This version does not fully support conditional definitions! With an option foo of this type and a definition foo.attr = lib.mkIf false 10, evaluating foo ? attr will return true even though it should be false. Accessing the value will then throw an error. For types t that have an emptyValue defined, that value will be returned instead of throwing an error. So if the type of foo.attr was lazyAttrsOf (nullOr int), null would be returned instead for the same mkIf false definition.

Noogle detected

Implementation

The following is the current implementation of this function.

lazyAttrsOf =
    elemType:
    attrsWith {
      inherit elemType;
      lazy = true;
    };