From 0461f3589499168867e2de88c78f32e44c8ed557 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 20 Mar 2015 19:23:55 +0100 Subject: Rename scrubDrv -> hydraJob and make it more effective It now strictly evaluates all remaining attributes, preventing unevaluated thunks that cannot be garbage-collected. It's also applied to all jobs in Nixpkgs' release.nix. This reduces hydra-eval-jobs' memory consumption on the 14.12 release-combined jobset from 5.1 GB to 2.0 GB. --- lib/customisation.nix | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'lib') diff --git a/lib/customisation.nix b/lib/customisation.nix index f16043cf9a3e..960eebfc79b5 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -105,6 +105,7 @@ rec { let f = if builtins.isFunction fn then fn else import fn; in makeOverridable f ((builtins.intersectAttrs (builtins.functionArgs f) autoArgs) // args); + /* Add attributes to each output of a derivation without changing the derivation itself */ addPassthru = drv: passthru: let @@ -122,4 +123,38 @@ rec { outputsList = map outputToAttrListElement outputs; in commonAttrs.${drv.outputName}; + + + /* 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 + garbage collection. */ + hydraJob = drv: + let + outputs = drv.outputs or ["out"]; + + commonAttrs = + { inherit (drv) name system meta; inherit outputs; } + // lib.optionalAttrs (drv._hydraAggregate or false) { + _hydraAggregate = true; + constituents = map hydraJob (lib.flatten drv.constituents); + } + // (lib.listToAttrs outputsList); + + makeOutput = outputName: + let output = drv.${outputName}; in + { name = outputName; + value = commonAttrs // { + outPath = output.outPath; + drvPath = output.drvPath; + type = "derivation"; + inherit outputName; + }; + }; + + outputsList = map makeOutput outputs; + + drv' = (lib.head outputsList).value; + in lib.deepSeq drv' drv'; + } -- cgit 1.4.1