2017-09-10 19:36:48 +00:00
|
|
|
{ stdenv, targetPackages
|
|
|
|
, buildPlatform, hostPlatform, targetPlatform
|
2017-01-24 23:00:54 +00:00
|
|
|
|
2017-09-10 19:36:48 +00:00
|
|
|
# build-tools
|
|
|
|
, bootPkgs, alex, happy
|
|
|
|
, autoconf, automake, coreutils, fetchgit, perl, python3
|
|
|
|
|
|
|
|
, libiconv ? null, ncurses
|
|
|
|
|
|
|
|
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
|
2017-01-24 23:00:54 +00:00
|
|
|
# library instead of the faster but GPLed integer-gmp library.
|
2017-09-10 19:36:48 +00:00
|
|
|
enableIntegerSimple ? false, gmp ? null
|
|
|
|
|
2017-12-09 10:52:13 +00:00
|
|
|
, version ? "8.5.20171209"
|
2015-12-16 18:18:29 +00:00
|
|
|
}:
|
2015-01-16 18:31:34 +00:00
|
|
|
|
2017-09-10 19:36:48 +00:00
|
|
|
assert !enableIntegerSimple -> gmp != null;
|
|
|
|
|
2016-02-21 18:15:04 +00:00
|
|
|
let
|
|
|
|
inherit (bootPkgs) ghc;
|
|
|
|
|
2017-12-09 10:52:13 +00:00
|
|
|
rev = "4335c07ca7e64624819b22644d7591853826bd75";
|
2016-11-15 21:59:09 +00:00
|
|
|
|
2017-09-10 19:36:48 +00:00
|
|
|
# TODO(@Ericson2314) Make unconditional
|
|
|
|
targetPrefix = stdenv.lib.optionalString
|
|
|
|
(targetPlatform != hostPlatform)
|
|
|
|
"${targetPlatform.config}-";
|
2017-09-10 22:29:27 +00:00
|
|
|
|
|
|
|
buildMK = stdenv.lib.optionalString enableIntegerSimple ''
|
|
|
|
INTEGER_LIBRARY = integer-simple
|
|
|
|
'' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
|
|
|
|
BuildFlavour = perf-cross
|
|
|
|
'';
|
2017-09-10 19:36:48 +00:00
|
|
|
in
|
2017-02-02 16:44:11 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2017-01-07 03:10:29 +00:00
|
|
|
inherit version rev;
|
2018-01-03 21:29:18 +00:00
|
|
|
name = "${targetPrefix}ghc-${version}";
|
2011-08-08 19:47:31 +00:00
|
|
|
|
2015-02-12 20:18:06 +00:00
|
|
|
src = fetchgit {
|
|
|
|
url = "git://git.haskell.org/ghc.git";
|
|
|
|
inherit rev;
|
2017-12-09 10:52:13 +00:00
|
|
|
sha256 = "19csad94sk0bw2nj97ppmnwh4c193jg0jmg5w2sx9rqm9ih4yg85";
|
2010-09-28 13:48:22 +00:00
|
|
|
};
|
|
|
|
|
2016-12-24 17:37:58 +00:00
|
|
|
postPatch = "patchShebangs .";
|
|
|
|
|
2017-09-10 18:50:00 +00:00
|
|
|
preConfigure = ''
|
2017-09-18 16:04:22 +00:00
|
|
|
echo -n "${buildMK}" > mk/build.mk
|
2017-09-10 18:50:00 +00:00
|
|
|
echo ${version} >VERSION
|
|
|
|
echo ${rev} >GIT_COMMIT_ID
|
|
|
|
./boot
|
|
|
|
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
|
|
|
'' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
|
2017-09-10 22:29:27 +00:00
|
|
|
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
2017-09-10 18:50:00 +00:00
|
|
|
'' + stdenv.lib.optionalString stdenv.isDarwin ''
|
|
|
|
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
|
|
|
'';
|
2015-02-03 23:34:08 +00:00
|
|
|
|
2017-09-10 18:50:00 +00:00
|
|
|
buildInputs = [ ghc perl autoconf automake happy alex python3 ];
|
2010-09-28 13:48:22 +00:00
|
|
|
|
2015-12-16 18:18:29 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2014-12-18 16:31:37 +00:00
|
|
|
configureFlags = [
|
2016-11-15 23:30:26 +00:00
|
|
|
"CC=${stdenv.cc}/bin/cc"
|
2016-02-01 17:16:50 +00:00
|
|
|
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
2017-06-17 19:13:01 +00:00
|
|
|
"--datadir=$doc/share/doc/ghc"
|
2017-01-24 23:00:54 +00:00
|
|
|
] ++ stdenv.lib.optional (! enableIntegerSimple) [
|
|
|
|
"--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib"
|
2015-12-16 18:18:29 +00:00
|
|
|
] ++ stdenv.lib.optional stdenv.isDarwin [
|
|
|
|
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
|
2014-12-18 16:31:37 +00:00
|
|
|
];
|
|
|
|
|
2010-09-28 13:48:22 +00:00
|
|
|
# required, because otherwise all symbols from HSffi.o are stripped, and
|
|
|
|
# that in turn causes GHCi to abort
|
2017-09-10 19:36:48 +00:00
|
|
|
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
2010-09-28 13:48:22 +00:00
|
|
|
|
2016-12-24 17:37:04 +00:00
|
|
|
checkTarget = "test";
|
|
|
|
|
2015-12-16 18:18:29 +00:00
|
|
|
postInstall = ''
|
2017-09-10 19:36:48 +00:00
|
|
|
paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"}
|
2016-12-15 00:25:58 +00:00
|
|
|
|
2015-12-16 18:18:29 +00:00
|
|
|
# Install the bash completion file.
|
2017-09-10 19:36:48 +00:00
|
|
|
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
2015-12-16 18:18:29 +00:00
|
|
|
|
|
|
|
# Patch scripts to include "readelf" and "cat" in $PATH.
|
|
|
|
for i in "$out/bin/"*; do
|
|
|
|
test ! -h $i || continue
|
|
|
|
egrep --quiet '^#!' <(head -n 1 $i) || continue
|
2017-10-18 18:05:39 +00:00
|
|
|
sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
|
2015-12-16 18:18:29 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2017-06-22 18:52:35 +00:00
|
|
|
outputs = [ "out" "doc" ];
|
|
|
|
|
2016-02-21 18:15:04 +00:00
|
|
|
passthru = {
|
2017-09-10 19:36:48 +00:00
|
|
|
inherit bootPkgs targetPrefix;
|
2016-02-21 18:15:04 +00:00
|
|
|
};
|
|
|
|
|
2010-09-28 13:48:22 +00:00
|
|
|
meta = {
|
2017-08-01 20:03:30 +00:00
|
|
|
homepage = http://haskell.org/ghc;
|
2010-09-28 13:48:22 +00:00
|
|
|
description = "The Glasgow Haskell Compiler";
|
2016-05-16 20:30:20 +00:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
|
2013-03-23 12:05:43 +00:00
|
|
|
inherit (ghc.meta) license platforms;
|
2010-09-28 13:48:22 +00:00
|
|
|
};
|
|
|
|
|
2017-02-02 16:44:11 +00:00
|
|
|
}
|