query
On this page

extendDerivation

lib.extendDerivation

Docs pulled from | This Revision | 43 minutes ago


Add attributes to each output of a derivation without changing the derivation itself and check a given condition when evaluating.

Inputs

condition

1. Function argument

passthru

2. Function argument

drv

3. Function argument

Type

extendDerivation :: Bool -> Any -> Derivation -> Derivation
(lib.customisation.extendDerivation)

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

extendDerivation =
    condition: passthru: drv:
    let
      outputs = drv.outputs or [ "out" ];

      commonAttrs =
        drv // (listToAttrs outputsList) // ({ all = map (x: x.value) outputsList; }) // passthru;

      outputToAttrListElement = outputName: {
        name = outputName;
        value =
          commonAttrs
          // {
            inherit (drv.${outputName}) type outputName;
            outputSpecified = true;
            drvPath =
              assert condition;
              drv.${outputName}.drvPath;
            outPath =
              assert condition;
              drv.${outputName}.outPath;
          }
          //
            # TODO: give the derivation control over the outputs.
            #       `overrideAttrs` may not be the only attribute that needs
            #       updating when switching outputs.
            optionalAttrs (passthru ? overrideAttrs) {
              # TODO: also add overrideAttrs when overrideAttrs is not custom, e.g. when not splicing.
              overrideAttrs = f: (passthru.overrideAttrs f).${outputName};
            };
      };

      outputsList = map outputToAttrListElement outputs;
    in
    commonAttrs
    // {
      drvPath =
        assert condition;
        drv.drvPath;
      outPath =
        assert condition;
        drv.outPath;
    };