diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-03-20 19:23:55 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-03-20 19:46:18 +0100 |
commit | 0461f3589499168867e2de88c78f32e44c8ed557 (patch) | |
tree | 364d7766e5b06e31be247303793928ff0ea67503 /lib | |
parent | 738cf42639c6e45b097bb1fd29508e95a36eb5c0 (diff) |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/customisation.nix | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix index f16043cf9a3e3..960eebfc79b53 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'; + } |