Haskell infrastructure: fix #9871 (overrideCabal)

As per the recommendation by @Mathnerd314, this change seems to work
with the testing I did.

It makes sense to me why it works, but I think it's in an important
enough place that someone with much deeper knowledge of Haskell
infrastructure in Nixpkgs should give it a really heavy review.

I also consolidated all the overrideCabal definitions (there were two)
into a single definition in haskell-modules/lib.nix.
This commit is contained in:
Sukant Hajra 2017-02-09 23:04:17 -06:00
parent 96d07508bf
commit 98617ccb99
2 changed files with 5 additions and 6 deletions

View File

@ -6,12 +6,13 @@
let
inherit (stdenv.lib) fix' extends;
inherit (stdenv.lib) fix' extends makeOverridable;
inherit (import ./lib.nix { inherit pkgs; }) overrideCabal;
haskellPackages = self:
let
mkDerivation = pkgs.callPackage ./generic-builder.nix {
mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
inherit stdenv;
inherit (pkgs) fetchurl pkgconfig glibcLocales coreutils gnugrep gnused;
jailbreak-cabal = if (self.ghc.cross or null) != null
@ -37,9 +38,7 @@ let
});
};
overrideCabal = drv: f: drv.override (args: args // {
mkDerivation = drv: args.mkDerivation (drv // f drv);
});
mkDerivation = makeOverridable mkDerivationImpl;
callPackageWithScope = scope: drv: args: (stdenv.lib.callPackageWith scope drv args) // {
overrideScope = f: callPackageWithScope (mkScope (fix' (extends f scope.__unfix__))) drv args;

View File

@ -3,7 +3,7 @@
rec {
overrideCabal = drv: f: (drv.override (args: args // {
mkDerivation = drv: args.mkDerivation (drv // f drv);
mkDerivation = drv: (args.mkDerivation drv).override f;
})) // {
overrideScope = scope: overrideCabal (drv.overrideScope scope) f;
};