query
On this page

extendDerivation

lib.extendDerivation

Docs pulled from | This Revision | 29 minutes ago


Nixpkgs manual

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
      commonAttrs =
        drv
        // listToAttrs (
          outputsList
          ++ [
            {
              name = "all";
              value = map (x: x.value) outputsList;
            }
          ]
        )
        // passthru
        // {
          drvPath =
            assert condition;
            drv.drvPath;
          outPath =
            assert condition;
            drv.outPath;
        };

      outputsList = map (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.
          # TODO: also add overrideAttrs when overrideAttrs is not custom, e.g. when not splicing.
          ${if passthru ? overrideAttrs then "overrideAttrs" else null} =
            f: (passthru.overrideAttrs f).${outputName};
        };
      }) (drv.outputs or [ "out" ]);
    in
    commonAttrs;