1{ pkgs, stdenv, ghc
2, compilerConfig ? (self: super: {})
3, packageSetConfig ? (self: super: {})
4, overrides ? (self: super: {})
5}:
6
7let
8
9 allCabalFiles = pkgs.fetchFromGitHub {
10 owner = "commercialhaskell";
11 repo = "all-cabal-hashes";
12 rev = "72f1318540eff69544eb8c14a16f630d0c5448b8";
13 sha256 = "1czi1rajk2726mqrw3qp7a43h26acbjw54ll3ns063yzg9hg469m";
14 };
15
16 inherit (stdenv.lib) fix' extends;
17
18 haskellPackages = self:
19 let
20
21 mkDerivation = pkgs.callPackage ./generic-builder.nix {
22 inherit stdenv;
23 inherit (pkgs) fetchurl pkgconfig glibcLocales coreutils gnugrep gnused;
24 inherit (self) ghc jailbreak-cabal;
25 hscolour = overrideCabal self.hscolour (drv: {
26 isLibrary = false;
27 doHaddock = false;
28 hyperlinkSource = false; # Avoid depending on hscolour for this build.
29 postFixup = "rm -rf $out/lib $out/share $out/nix-support";
30 });
31 cpphs = overrideCabal (self.cpphs.overrideScope (self: super: {
32 mkDerivation = drv: super.mkDerivation (drv // {
33 enableSharedExecutables = false;
34 enableSharedLibraries = false;
35 doHaddock = false;
36 useCpphs = false;
37 });
38 })) (drv: {
39 isLibrary = false;
40 postFixup = "rm -rf $out/lib $out/share $out/nix-support";
41 });
42 };
43
44 overrideCabal = drv: f: drv.override (args: args // {
45 mkDerivation = drv: args.mkDerivation (drv // f drv);
46 });
47
48 callPackageWithScope = scope: drv: args: (stdenv.lib.callPackageWith scope drv args) // {
49 overrideScope = f: callPackageWithScope (mkScope (fix' (extends f scope.__unfix__))) drv args;
50 };
51
52 mkScope = scope: pkgs // pkgs.xorg // pkgs.gnome // scope;
53 defaultScope = mkScope self;
54 callPackage = drv: args: callPackageWithScope defaultScope drv args;
55
56 withPackages = packages: callPackage ./with-packages-wrapper.nix {
57 inherit (self) llvmPackages;
58 haskellPackages = self;
59 inherit packages;
60 };
61
62 hackage2nix = name: version: pkgs.stdenv.mkDerivation {
63 name = "cabal2nix-${name}-${version}";
64 buildInputs = [ pkgs.cabal2nix ];
65 phases = ["installPhase"];
66 LANG = "en_US.UTF-8";
67 LOCALE_ARCHIVE = pkgs.lib.optionalString pkgs.stdenv.isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive";
68 installPhase = ''
69 export HOME="$TMP"
70 mkdir $out
71 hash=$(sed -e 's/.*"SHA256":"//' -e 's/".*$//' ${allCabalFiles}/${name}/${version}/${name}.json)
72 cabal2nix --compiler=${self.ghc.name} --system=${stdenv.system} --sha256=$hash ${allCabalFiles}/${name}/${version}/${name}.cabal >$out/default.nix
73 '';
74 };
75
76 in
77 import ./hackage-packages.nix { inherit pkgs stdenv callPackage; } self // {
78
79 inherit mkDerivation callPackage;
80
81 callHackage = name: version: self.callPackage (hackage2nix name version);
82
83 ghcWithPackages = selectFrom: withPackages (selectFrom self);
84
85 ghcWithHoogle = selectFrom:
86 let
87 packages = selectFrom self;
88 hoogle = callPackage ./hoogle.nix { inherit packages; };
89 in withPackages (packages ++ [ hoogle ]);
90
91 ghc = ghc // {
92 withPackages = self.ghcWithPackages;
93 withHoogle = self.ghcWithHoogle;
94 };
95
96 };
97
98 commonConfiguration = import ./configuration-common.nix { inherit pkgs; };
99
100in
101
102 fix'
103 (extends overrides
104 (extends packageSetConfig
105 (extends compilerConfig
106 (extends commonConfiguration haskellPackages))))