Noogλe

search input

Function of the day

  • Apply a function to each leaf (non‐attribute‐set attribute) of a tree of nested attribute sets, returning the results of the function as a list, ordered lexicographically by their attribute paths.

    Like mapAttrsRecursive, but concatenates the mapping function results into a list.

    Inputs

    f

    Mapping function which, given an attribute’s path and value, returns a new value.

    This value will be an element of the list returned by mapAttrsToListRecursive.

    The first argument to the mapping function is a list of attribute names forming the path to the leaf attribute. The second argument is the leaf attribute value, which will never be an attribute set.

    set

    Attribute set to map over.

    Type

    mapAttrsToListRecursive :: ([String] -> a -> b) -> AttrSet -> [b]
    

    Examples

    lib.attrsets.mapAttrsToListRecursive usage example

    mapAttrsToListRecursive (path: value: "${concatStringsSep "." path}=${value}")
      { n = { a = "A"; m = { b = "B"; c = "C"; }; }; d = "D"; }
    => [ "n.a=A" "n.m.b=B" "n.m.c=C" "d=D" ]