Skip to content

Commit

Permalink
overrideDerivation: fix meta handling (closes NixOS#7425)
Browse files Browse the repository at this point in the history
stdenv.mkDerivation already implements the complicated addPassthru logic and
calls derivation for us, in particular filtering out "meta". Using it ensures
the invariant that
mkDerivation{<a>}.overrideDerivation{<b>} == mkDerivation{<a and b>}
Also, we give meta/passthru to the function, so that calls of the form
overrideDerivation(drv: meta = drv.meta // ...) work. Finally, we use
isFunction and recursiveMerge so that overrideDerivation { meta.x = y; }
works as well.
  • Loading branch information
Mathnerd314 committed Aug 19, 2015
1 parent ab7a164 commit 788fd51
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
18 changes: 3 additions & 15 deletions lib/customisation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,9 @@ rec {
*/
overrideDerivation = drv: f:
let
newDrv = derivation (drv.drvAttrs // (f drv));
in addPassthru newDrv (
{ meta = drv.meta or {};
passthru = if drv ? passthru then drv.passthru else {};
}
//
(drv.passthru or {})
//
(if (drv ? crossDrv && drv ? nativeDrv)
then {
crossDrv = overrideDerivation drv.crossDrv f;
nativeDrv = overrideDerivation drv.nativeDrv f;
}
else { }));

oldDrv = drv.drvAttrs // { meta = drv.meta or {}; passthru = drv.passthru or {}; crossAttrs = drv.crossAttrs or {}; };
newDrv = if builtins.isFunction f then f oldDrv else f;
in drv.stdenv.mkDerivation (lib.recursiveUpdate oldDrv newDrv);

makeOverridable = f: origArgs:
let
Expand Down
3 changes: 2 additions & 1 deletion pkgs/stdenv/generic/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ let
, crossConfig ? null
, meta ? {}
, passthru ? {}
, crossAttrs ? {}
, pos ? null # position used in error messages and for meta.position
, ... } @ attrs:
let
Expand Down Expand Up @@ -185,7 +186,7 @@ let
meta = meta // (if pos' != null then {
position = pos'.file + ":" + toString pos'.line;
} else {});
inherit passthru;
inherit passthru crossAttrs;
} //
# Pass through extra attributes that are not inputs, but
# should be made available to Nix expressions using the
Expand Down

0 comments on commit 788fd51

Please sign in to comment.