query
On this page

optionalAttrs

lib.attrsets.optionalAttrs

Docs pulled from | This Revision | 34 minutes ago


If cond is true, return the attribute set as, otherwise an empty attribute set.

Inputs

cond

Condition under which the as attribute set is returned.

as

The attribute set to return if cond is true.

Type

optionalAttrs :: Bool -> AttrSet -> AttrSet

Examples

lib.attrsets.optionalAttrs usage example

optionalAttrs (true) { my = "set"; }
=> { my = "set"; }
optionalAttrs (false) { my = "set"; }
=> { }

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

optionalAttrs =
    cond:
    as:
    if cond then as else {};