forked from mirrors/nixpkgs
overrideDerivation: Simplify
Since we're just calling derivation again, drvAttrs is exactly what we want to pass, and we can get rid of the complicated "drop" logic. As a bonus, this actually makes it correct, since before "drop" removed the attribute named passthru but not actually the attributes added to the top-level attrset via passthru. Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
parent
1c2565a8ef
commit
6640000cb7
|
@ -33,17 +33,14 @@ rec {
|
||||||
|
|
||||||
overrideDerivation = drv: f:
|
overrideDerivation = drv: f:
|
||||||
let
|
let
|
||||||
# Filter out special attributes.
|
newDrv = derivation (drv.drvAttrs // (f drv));
|
||||||
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 //
|
in newDrv //
|
||||||
{ meta = if drv ? meta then drv.meta else {};
|
{ meta = drv.meta or {};
|
||||||
passthru = if drv ? passthru then drv.passthru else {};
|
passthru = if drv ? passthru then drv.passthru else {};
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
(drv.passthru or {})
|
||||||
|
//
|
||||||
(if (drv ? crossDrv && drv ? nativeDrv)
|
(if (drv ? crossDrv && drv ? nativeDrv)
|
||||||
then {
|
then {
|
||||||
crossDrv = overrideDerivation drv.crossDrv f;
|
crossDrv = overrideDerivation drv.crossDrv f;
|
||||||
|
|
Loading…
Reference in a new issue