Revert "Revert "Revert "overrideDerivation: Simplify"""

This reverts commit c2b1ca0296.

It still breaks VM builds: http://hydra.nixos.org/build/4858140
This commit is contained in:
Eelco Dolstra 2013-05-07 10:49:22 +02:00
parent 18df66f466
commit abf2d36773

View file

@ -33,14 +33,17 @@ rec {
overrideDerivation = drv: f:
let
newDrv = derivation (drv.drvAttrs // (f drv));
# Filter out special attributes.
drop = [ "meta" "passthru" "outPath" "drvPath" "crossDrv" "nativeDrv" "type" "override" "deepOverride" "origArgs" "drvAttrs" "outputName" "all" "out" ]
# also drop functions such as .merge .override etc
++ lib.filter (n: isFunction (getAttr n drv)) (attrNames drv);
attrs = removeAttrs drv drop;
newDrv = derivation (attrs // (f drv));
in newDrv //
{ meta = drv.meta or {};
{ meta = if drv ? meta then drv.meta else {};
passthru = if drv ? passthru then drv.passthru else {};
}
//
(drv.passthru or {})
//
(if (drv ? crossDrv && drv ? nativeDrv)
then {
crossDrv = overrideDerivation drv.crossDrv f;