2015-01-07 20:31:32 +01:00
|
|
|
{ pkgs, stdenv, ghc
|
2015-09-16 09:19:56 +02:00
|
|
|
, compilerConfig ? (self: super: {})
|
2015-01-07 20:31:32 +01:00
|
|
|
, packageSetConfig ? (self: super: {})
|
|
|
|
, overrides ? (self: super: {})
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2016-10-05 19:03:40 +02:00
|
|
|
allCabalFiles = stdenv.mkDerivation {
|
|
|
|
name = "all-cabal-hashes-0";
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out
|
|
|
|
tar -C $out --strip-components=1 -x -f ${builtins.fetchurl "https://github.com/commercialhaskell/all-cabal-hashes/archive/hackage.tar.gz"}
|
|
|
|
'';
|
|
|
|
};
|
2015-01-07 20:31:32 +01:00
|
|
|
|
2016-06-13 18:32:44 +02:00
|
|
|
inherit (stdenv.lib) fix' extends;
|
2016-06-11 19:21:19 +02:00
|
|
|
|
2015-01-07 20:31:32 +01:00
|
|
|
haskellPackages = self:
|
|
|
|
let
|
|
|
|
|
|
|
|
mkDerivation = pkgs.callPackage ./generic-builder.nix {
|
2015-01-10 12:50:43 +01:00
|
|
|
inherit stdenv;
|
2015-01-07 20:31:32 +01:00
|
|
|
inherit (pkgs) fetchurl pkgconfig glibcLocales coreutils gnugrep gnused;
|
2015-01-10 12:50:43 +01:00
|
|
|
inherit (self) ghc jailbreak-cabal;
|
2015-01-07 20:31:32 +01:00
|
|
|
hscolour = overrideCabal self.hscolour (drv: {
|
|
|
|
isLibrary = false;
|
2015-01-18 11:04:38 +01:00
|
|
|
doHaddock = false;
|
2015-01-07 20:31:32 +01:00
|
|
|
hyperlinkSource = false; # Avoid depending on hscolour for this build.
|
|
|
|
postFixup = "rm -rf $out/lib $out/share $out/nix-support";
|
|
|
|
});
|
2015-01-13 22:15:29 +01:00
|
|
|
cpphs = overrideCabal (self.cpphs.overrideScope (self: super: {
|
|
|
|
mkDerivation = drv: super.mkDerivation (drv // {
|
|
|
|
enableSharedExecutables = false;
|
|
|
|
enableSharedLibraries = false;
|
2015-01-18 11:04:38 +01:00
|
|
|
doHaddock = false;
|
2015-01-13 22:15:29 +01:00
|
|
|
useCpphs = false;
|
|
|
|
});
|
|
|
|
})) (drv: {
|
|
|
|
isLibrary = false;
|
|
|
|
postFixup = "rm -rf $out/lib $out/share $out/nix-support";
|
|
|
|
});
|
2015-01-07 20:31:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
overrideCabal = drv: f: drv.override (args: args // {
|
|
|
|
mkDerivation = drv: args.mkDerivation (drv // f drv);
|
|
|
|
});
|
|
|
|
|
2015-01-08 18:29:37 +01:00
|
|
|
callPackageWithScope = scope: drv: args: (stdenv.lib.callPackageWith scope drv args) // {
|
2015-11-24 13:06:58 +01:00
|
|
|
overrideScope = f: callPackageWithScope (mkScope (fix' (extends f scope.__unfix__))) drv args;
|
2015-01-08 18:29:37 +01:00
|
|
|
};
|
|
|
|
|
2016-09-11 23:24:51 +02:00
|
|
|
mkScope = scope: pkgs // pkgs.xorg // pkgs.gnome2 // scope;
|
2015-05-18 10:55:29 +02:00
|
|
|
defaultScope = mkScope self;
|
|
|
|
callPackage = drv: args: callPackageWithScope defaultScope drv args;
|
2015-01-07 20:31:32 +01:00
|
|
|
|
2015-08-17 21:45:13 +02:00
|
|
|
withPackages = packages: callPackage ./with-packages-wrapper.nix {
|
|
|
|
inherit (self) llvmPackages;
|
|
|
|
haskellPackages = self;
|
|
|
|
inherit packages;
|
|
|
|
};
|
|
|
|
|
2016-06-13 18:32:44 +02:00
|
|
|
hackage2nix = name: version: pkgs.stdenv.mkDerivation {
|
|
|
|
name = "cabal2nix-${name}-${version}";
|
|
|
|
buildInputs = [ pkgs.cabal2nix ];
|
|
|
|
phases = ["installPhase"];
|
|
|
|
LANG = "en_US.UTF-8";
|
|
|
|
LOCALE_ARCHIVE = pkgs.lib.optionalString pkgs.stdenv.isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive";
|
|
|
|
installPhase = ''
|
|
|
|
export HOME="$TMP"
|
|
|
|
mkdir $out
|
|
|
|
hash=$(sed -e 's/.*"SHA256":"//' -e 's/".*$//' ${allCabalFiles}/${name}/${version}/${name}.json)
|
|
|
|
cabal2nix --compiler=${self.ghc.name} --system=${stdenv.system} --sha256=$hash ${allCabalFiles}/${name}/${version}/${name}.cabal >$out/default.nix
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-01-07 20:31:32 +01:00
|
|
|
in
|
|
|
|
import ./hackage-packages.nix { inherit pkgs stdenv callPackage; } self // {
|
|
|
|
|
2015-01-10 12:50:43 +01:00
|
|
|
inherit mkDerivation callPackage;
|
2015-01-07 20:31:32 +01:00
|
|
|
|
2016-06-11 19:21:19 +02:00
|
|
|
callHackage = name: version: self.callPackage (hackage2nix name version);
|
|
|
|
|
2015-08-17 21:45:13 +02:00
|
|
|
ghcWithPackages = selectFrom: withPackages (selectFrom self);
|
2015-01-07 20:31:32 +01:00
|
|
|
|
2015-08-17 21:45:13 +02:00
|
|
|
ghcWithHoogle = selectFrom:
|
|
|
|
let
|
|
|
|
packages = selectFrom self;
|
2016-09-03 16:35:19 +02:00
|
|
|
hoogle = callPackage ./hoogle.nix {
|
|
|
|
inherit packages;
|
2016-09-12 12:00:38 +02:00
|
|
|
hoogle = self.hoogle_5_0_4;
|
2016-09-03 16:35:19 +02:00
|
|
|
};
|
2015-08-17 21:45:13 +02:00
|
|
|
in withPackages (packages ++ [ hoogle ]);
|
|
|
|
|
|
|
|
ghc = ghc // {
|
|
|
|
withPackages = self.ghcWithPackages;
|
|
|
|
withHoogle = self.ghcWithHoogle;
|
|
|
|
};
|
2015-01-10 12:50:43 +01:00
|
|
|
|
2015-01-07 20:31:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
commonConfiguration = import ./configuration-common.nix { inherit pkgs; };
|
|
|
|
|
|
|
|
in
|
|
|
|
|
2015-11-24 13:06:58 +01:00
|
|
|
fix'
|
|
|
|
(extends overrides
|
|
|
|
(extends packageSetConfig
|
|
|
|
(extends compilerConfig
|
|
|
|
(extends commonConfiguration haskellPackages))))
|