@@ -0,0 +1,70 @@
1+{ stdenv, fetchurl, fetchpatch, ghc, perl, gmp, ncurses, libiconv, binutils, coreutils
2+, libxml2, libxslt, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, hscolour
3+}:
4+
5+let
6+
7+ buildMK = ''
8+ libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp}/lib"
9+ libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp}/include"
10+ libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses}/include"
11+ libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses}/lib"
12+ ${stdenv.lib.optionalString stdenv.isDarwin ''
13+ libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="${libiconv}/include"
14+ libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib"
15+ ''}
16+ '';
17+
18+in
19+
20+stdenv.mkDerivation rec {
21+ version = "7.10.3";
22+ name = "ghc-${version}";
23+
24+ src = fetchurl {
25+ url = "https://downloads.haskell.org/~ghc/${version}/${name}-src.tar.xz";
26+ sha256 = "1vsgmic8csczl62ciz51iv8nhrkm72lyhbz7p7id13y2w7fcx46g";
27+ };
28+
29+ buildInputs = [ ghc perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42 hscolour ];
30+
31+ enableParallelBuilding = true;
32+
33+ preConfigure = ''
34+ echo >mk/build.mk "${buildMK}"
35+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
36+ '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
37+ export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}"
38+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
39+ export NIX_LDFLAGS+=" -no_dtrace_dof"
40+ '';
41+
42+ configureFlags = [
43+ "--with-gcc=${stdenv.cc}/bin/cc"
44+ "--with-gmp-includes=${gmp}/include" "--with-gmp-libraries=${gmp}/lib"
45+ ];
46+
47+ # required, because otherwise all symbols from HSffi.o are stripped, and
48+ # that in turn causes GHCi to abort
49+ stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
50+
51+ postInstall = ''
52+ # Install the bash completion file.
53+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc
54+
55+ # Patch scripts to include "readelf" and "cat" in $PATH.
56+ for i in "$out/bin/"*; do
57+ test ! -h $i || continue
58+ egrep --quiet '^#!' <(head -n 1 $i) || continue
59+ sed -i -e '2i export PATH="$PATH:${binutils}/bin:${coreutils}/bin"' $i
60+ done
61+ '';
62+
63+ meta = {
64+ homepage = "http://haskell.org/ghc";
65+ description = "The Glasgow Haskell Compiler";
66+ maintainers = with stdenv.lib.maintainers; [ marcweber andres simons ];
67+ inherit (ghc.meta) license platforms;
68+ };
69+
70+}