optionalAttrs
lib.attrsets.optionalAttrs
Docs pulled from | This Revision | 4 days ago
If cond is true, return the attribute set as,
otherwise an empty attribute set.
Inputs
cond-
Condition under which the
asattribute set is returned. as-
The attribute set to return if
condistrue.
Type
optionalAttrs :: Bool -> AttrSet -> AttrSet
Examples
lib.attrsets.optionalAttrs usage example
optionalAttrs (true) { my = "set"; }
=> { my = "set"; }
optionalAttrs (false) { my = "set"; }
=> { }
Noogle detected
Implementation
The following is the current implementation of this function.
optionalAttrs = cond: as: if cond then as else { };