optionalDrvAttr
lib.derivations.optionalDrvAttr
Docs pulled from | This Revision | about 1 hour ago
Conditionally set a derivation attribute.
Because mkDerivation sets __ignoreNulls = true, a derivation
attribute set to null will not impact the derivation output hash.
Thus, this function passes through its value argument if the cond
is true, but returns null if not.
Inputs
cond-
Condition
value-
Attribute value
Type
optionalDrvAttr :: Bool -> a -> a | Null
Examples
lib.derivations.optionalDrvAttr usage example
(stdenv.mkDerivation {
name = "foo";
x = optionalDrvAttr true 1;
y = optionalDrvAttr false 1;
}).drvPath == (stdenv.mkDerivation {
name = "foo";
x = 1;
}).drvPath
=> true
Noogle detected
Implementation
The following is the current implementation of this function.
optionalDrvAttr = cond: value: if cond then value else null;