Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make-derivation.nix: allow equality-test of meta-check-failing derivations #213096

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lib/customisation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ rec {

/* Add attributes to each output of a derivation without changing
the derivation itself and check a given condition when evaluating. */
extendDerivation = condition: passthru: drv:
extendDerivation' = { conditionDrvPath, conditionOutPath, ... }@args: passthru: drv:
let
outputs = drv.outputs or [ "out" ];

Expand All @@ -211,17 +211,26 @@ rec {
value = commonAttrs // {
inherit (drv.${outputName}) type outputName;
outputSpecified = true;
drvPath = assert condition; drv.${outputName}.drvPath;
outPath = assert condition; drv.${outputName}.outPath;
drvPath = assert conditionDrvPath; drv.${outputName}.drvPath;
outPath = assert conditionOutPath; drv.${outputName}.outPath;
__toString = _: assert args.conditionDrvPath; drv.${drv.outputName}.outPath;
};
};

outputsList = map outputToAttrListElement outputs;
in commonAttrs // {
drvPath = assert condition; drv.drvPath;
outPath = assert condition; drv.outPath;
drvPath = assert conditionDrvPath; drv.drvPath;
outPath = assert conditionOutPath; drv.outPath;
__toString = _: assert args.conditionDrvPath; drv.outPath;
};

/* extendDerivation' with the same condition for both outPath and drvPath */
extendDerivation = condition: passthru: drv:
extendDerivation' {
conditionDrvPath = condition;
conditionOutPath = condition;
} passthru drv;

/* Strip a derivation of all non-essential attributes, returning
only those needed by hydra-eval-jobs. Also strictly evaluate the
result to ensure that there are no thunks kept alive to prevent
Expand Down
10 changes: 8 additions & 2 deletions pkgs/stdenv/generic/make-derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,14 @@ else let

in

lib.extendDerivation
validity.handled
lib.customisation.extendDerivation'
{
# setting `conditionOutPath` to be trivially satisfied lets us
# compare meta-check-failing derivations for equality against
# each other without a `throw` occurring.
conditionOutPath = true;
conditionDrvPath = validity.handled;
}
({
# A derivation that always builds successfully and whose runtime
# dependencies are the original derivations build time dependencies
Expand Down