Noogλe
Function of the day
Restrict a derivation to a predictable set of attribute names, so that the returned attrset is not strict in the actual derivation, saving a lot of computation when the derivation is non-trivial.
This is useful in situations where a derivation might only be used for its passthru attributes, improving evaluation performance.
The returned attribute set is lazy in
derivation. Specifically, this means that the derivation will not be evaluated in at least the situations below.For illustration and/or testing, we define derivation such that its evaluation is very noticeable.
let derivation = throw "This won't be evaluated.";In the following expressions,
derivationwill not be evaluated:(lazyDerivation { inherit derivation; }).type attrNames (lazyDerivation { inherit derivation; }) (lazyDerivation { inherit derivation; } // { foo = true; }).foo (lazyDerivation { inherit derivation; meta.foo = true; }).metaIn these expressions,
derivationwill be evaluated:"${lazyDerivation { inherit derivation }}" (lazyDerivation { inherit derivation }).outPath (lazyDerivation { inherit derivation }).metaAnd the following expressions are not valid, because the refer to implementation details and/or attributes that may not be present on some derivations:
(lazyDerivation { inherit derivation }).buildInputs (lazyDerivation { inherit derivation }).passthru (lazyDerivation { inherit derivation }).pythonPathInputs
Takes an attribute set with the following attributes
derivation- The derivation to be wrapped.
meta- Optional meta attribute.
While this function is primarily about derivations, it can improve
the
metapackage attribute, which is usually specified throughmkDerivation. passthru- Optional extra values to add to the returned attrset.
This can be used for adding package attributes, such as
tests. outputs- Optional list of assumed outputs. Default:
[ "out" ]This must match the set of outputs that the returned derivation has. You must use this when the derivation has multiple outputs.