1{ pkgs, stdenv, ghc
2, packageSetConfig ? (self: super: {})
3, overrides ? (self: super: {})
4}:
5
6let
7
8 fix = f: let x = f x // { __unfix__ = f; }; in x;
9
10 extend = rattrs: f: self: let super = rattrs self; in super // f self super;
11
12 haskellPackages = self:
13 let
14
15 mkDerivation = pkgs.callPackage ./generic-builder.nix {
16 inherit stdenv;
17 inherit (pkgs) fetchurl pkgconfig glibcLocales coreutils gnugrep gnused;
18 inherit (self) ghc jailbreak-cabal;
19 hscolour = overrideCabal self.hscolour (drv: {
20 isLibrary = false;
21 doHaddock = false;
22 hyperlinkSource = false; # Avoid depending on hscolour for this build.
23 postFixup = "rm -rf $out/lib $out/share $out/nix-support";
24 });
25 cpphs = overrideCabal (self.cpphs.overrideScope (self: super: {
26 mkDerivation = drv: super.mkDerivation (drv // {
27 enableSharedExecutables = false;
28 enableSharedLibraries = false;
29 doHaddock = false;
30 useCpphs = false;
31 });
32 })) (drv: {
33 isLibrary = false;
34 postFixup = "rm -rf $out/lib $out/share $out/nix-support";
35 });
36 };
37
38 overrideCabal = drv: f: drv.override (args: args // {
39 mkDerivation = drv: args.mkDerivation (drv // f drv);
40 });
41
42 callPackageWithScope = scope: drv: args: (stdenv.lib.callPackageWith scope drv args) // {
43 overrideScope = f: callPackageWithScope (mkScope (fix (extend scope.__unfix__ f))) drv args;
44 };
45
46 mkScope = scope: pkgs // pkgs.xlibs // pkgs.gnome // scope;
47 defaultScope = mkScope self;
48 callPackage = drv: args: callPackageWithScope defaultScope drv args;
49
50 withPackages = packages: callPackage ./with-packages-wrapper.nix {
51 inherit (self) llvmPackages;
52 haskellPackages = self;
53 inherit packages;
54 };
55
56 in
57 import ./hackage-packages.nix { inherit pkgs stdenv callPackage; } self // {
58
59 inherit mkDerivation callPackage;
60
61 ghcWithPackages = selectFrom: withPackages (selectFrom self);
62
63 ghcWithHoogle = selectFrom:
64 let
65 packages = selectFrom self;
66 hoogle = callPackage ./hoogle.nix { inherit packages; };
67 in withPackages (packages ++ [ hoogle ]);
68
69 ghc = ghc // {
70 withPackages = self.ghcWithPackages;
71 withHoogle = self.ghcWithHoogle;
72 };
73
74 };
75
76 commonConfiguration = import ./configuration-common.nix { inherit pkgs; };
77
78in
79
80 fix (extend (extend (extend haskellPackages commonConfiguration) packageSetConfig) overrides)