attrsToList
lib.attrsets.attrsToList
Docs pulled from | This Revision | 17 minutes ago
Deconstruct an attrset to a list of name-value pairs as expected by builtins.listToAttrs
.
Each element of the resulting list is an attribute set with these attributes:
name
(string): The name of the attributevalue
(any): The value of the attribute
The following is always true:
builtins.listToAttrs (attrsToList attrs) == attrs
The opposite is not always true. In general expect that
attrsToList (builtins.listToAttrs list) != list
This is because the listToAttrs
removes duplicate names and doesn't preserve the order of the list.
Inputs
set
-
The attribute set to deconstruct.
Type
attrsToList :: AttrSet -> [ { name :: String; value :: Any; } ]
Examples
lib.attrsets.attrsToList
usage example
attrsToList { foo = 1; bar = "asdf"; }
=> [ { name = "bar"; value = "asdf"; } { name = "foo"; value = 1; } ]