query
On this page

optionalDrvAttr

lib.derivations.optionalDrvAttr

Docs pulled from | This Revision | about 12 hours 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 also knows

Aliases