Merge commit on master into staging

Doing this surgically so a future PR has a readable diff.
This commit is contained in:
John Ericson 2017-09-15 12:13:09 -04:00
commit 3befba542a
20 changed files with 272 additions and 132 deletions

@ -1,24 +1,29 @@
{stdenv, lib, fetchurl, perl, libedit, ncurses5, gmp}:
{ stdenv
, fetchurl, perl
, libedit, ncurses5, gmp
}:
# Prebuilt only does native
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec {
version = "6.10.2";
name = "ghc-${version}-binary";
src =
if stdenv.system == "i686-linux" then
fetchurl {
src = {
"i686-linux" = fetchurl {
# This binary requires libedit.so.0 (rather than libedit.so.2).
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2";
sha256 = "1fw0zr2qshlpk8s0d16k27zcv5263nqdg2xds5ymw8ff6qz9rz9b";
}
else if stdenv.system == "x86_64-linux" then
fetchurl {
};
"x86_64-linux" = fetchurl {
# Idem.
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2";
sha256 = "1rd2j7lmcfsm2rdfb5g6q0l8dz3sxadk5m3d2f69d4a6g4p4h7jj";
}
else throw "cannot bootstrap GHC on this platform";
};
}.${stdenv.hostPlatform.system}
or (throw "cannot bootstrap GHC on this platform");
buildInputs = [perl];
@ -37,17 +42,17 @@ stdenv.mkDerivation rec {
'' +
# On Linux, use patchelf to modify the executables so that they can
# find editline/gmp.
(if stdenv.isLinux then ''
stdenv.lib.optionalString stdenv.hostPlatform.isLinux ''
find . -type f -perm -0100 \
-exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${lib.makeLibraryPath [ libedit ncurses5 gmp ]}" {} \;
for prog in ld ar gcc strip ranlib; do
find . -name "setup-config" -exec sed -i "s@/usr/bin/$prog@$(type -p $prog)@g" {} \;
done
'' else "");
'';
configurePhase = ''
./configure --prefix=$out --with-gmp-libraries=${lib.getLib gmp}/lib --with-gmp-includes=${lib.getDev gmp}/include
./configure --prefix=$out --with-gmp-libraries=${stdenv.lib.getLib gmp}/lib --with-gmp-includes=${stdenv.lib.getDev gmp}/include
'';
# Stripping combined with patchelf breaks the executables (they die
@ -62,7 +67,7 @@ stdenv.mkDerivation rec {
# and create some wrapper scripts that set DYLD_FRAMEWORK_PATH so
# that the executables work with no special setup.
postInstall =
(if stdenv.isDarwin then
stdenv.lib.optionalString stdenv.hostPlatform.isDarwin
''
mkdir -p $out/frameworks/GMP.framework/Versions/A
ln -s ${gmp.out}/lib/libgmp.dylib $out/frameworks/GMP.framework/GMP
@ -79,7 +84,7 @@ stdenv.mkDerivation rec {
echo \"DYLD_FRAMEWORK_PATH=$out/frameworks exec $out/bin-orig/$i -framework-path $out/frameworks \\\"\\$@\\\"\" >> $out/bin/$i
chmod +x $out/bin/$i
done
'' else "")
''
+
''
# bah, the passing gmp doesn't work, so let's add it to the final package.conf in a quick but dirty way

@ -1,5 +1,8 @@
{stdenv, fetchurl, libedit, ghc, perl, gmp, ncurses}:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec {
version = "6.10.4";
@ -22,6 +25,8 @@ stdenv.mkDerivation rec {
NIX_CFLAGS_COMPILE = "-fomit-frame-pointer";
passthru = { prefix = ""; };
meta = {
homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler";

@ -1,5 +1,8 @@
{stdenv, fetchurl, ghc, perl, gmp, ncurses}:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec {
version = "6.12.3";
@ -33,6 +36,8 @@ stdenv.mkDerivation rec {
# that in turn causes GHCi to abort
stripDebugFlags=["-S" "--keep-file-symbols"];
passthru = { prefix = ""; };
meta = {
homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler";

@ -1,32 +1,35 @@
{stdenv, fetchurl, perl, ncurses5, gmp, libiconv}:
{ stdenv
, fetchurl, perl
, ncurses5, gmp, libiconv
}:
# Prebuilt only does native
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec {
version = "7.0.4";
name = "ghc-${version}-binary";
src =
if stdenv.system == "i686-linux" then
fetchurl {
src = {
"i686-linux" = fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2";
sha256 = "0mfnihiyjl06f5w1yrjp36sw9g67g2ymg5sdl0g23h1pab99jx63";
}
else if stdenv.system == "x86_64-linux" then
fetchurl {
};
"x86_64-linux" = fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2";
sha256 = "0mc4rhqcxz427wq4zgffmnn0d2yjqvy6af4x9mha283p1gdj5q99";
}
else if stdenv.system == "i686-darwin" then
fetchurl {
};
"i686-darwin" = fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2";
sha256 = "0qj45hslrrr8zfks8m1jcb3awwx9rh35ndnpfmb0gwb6j7azq5n3";
}
else if stdenv.system == "x86_64-darwin" then
fetchurl {
};
"x86_64-darwin" = fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2";
sha256 = "1m2ml88p1swf4dnv2vq8hz4drcp46n3ahpfi05wh01ajkf8hnn3l";
}
else throw "cannot bootstrap GHC on this platform";
};
}.${stdenv.hostPlatform.system}
or (throw "cannot bootstrap GHC on this platform");
buildInputs = [perl];

@ -1,5 +1,8 @@
{ stdenv, fetchurl, ghc, perl, gmp, ncurses, libiconv }:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec {
version = "7.0.4";
name = "ghc-${version}";
@ -42,6 +45,8 @@ stdenv.mkDerivation rec {
# that in turn causes GHCi to abort
stripDebugFlags=["-S" "--keep-file-symbols"];
passthru = { prefix = ""; };
meta = {
homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler";

@ -1,14 +1,28 @@
{ stdenv, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
, libxml2, libxslt, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, hscolour
{ stdenv, __targetPackages
, buildPlatform, hostPlatform, targetPlatform
# If enabled GHC will be build with the GPL-free but slower integer-simple
# build-tools
, bootPkgs, hscolour
, binutils, coreutils, fetchurl, fetchpatch, perl
, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, libxml2, libxslt
, ncurses, libiconv
, # If enabled GHC will be build with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp
enableIntegerSimple ? false, gmp ? null
}:
assert !enableIntegerSimple -> gmp != null;
let
inherit (bootPkgs) ghc;
# TODO(@Ericson2314) Make unconditional
prefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
buildMK = ''
libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses.dev}/include"
libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses.out}/lib"
@ -27,7 +41,7 @@ in
stdenv.mkDerivation rec {
version = "7.10.2";
name = "ghc-${version}";
name = "${prefix}ghc-${version}";
src = fetchurl {
url = "https://downloads.haskell.org/~ghc/7.10.2/${name}-src.tar.xz";
@ -64,7 +78,7 @@ stdenv.mkDerivation rec {
postInstall = ''
# Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${prefix}ghc
# Patch scripts to include "readelf" and "cat" in $PATH.
for i in "$out/bin/"*; do
@ -75,7 +89,7 @@ stdenv.mkDerivation rec {
'';
passthru = {
inherit bootPkgs;
inherit bootPkgs prefix;
};
meta = {

@ -1,14 +1,28 @@
{ stdenv, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
, libxml2, libxslt, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, hscolour
{ stdenv, __targetPackages
, buildPlatform, hostPlatform, targetPlatform
# If enabled GHC will be build with the GPL-free but slower integer-simple
# build-tools
, bootPkgs, hscolour
, binutils, coreutils, fetchurl, fetchpatch, perl
, docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, libxml2, libxslt
, ncurses, libiconv
, # If enabled GHC will be build with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp
enableIntegerSimple ? false, gmp ? null
}:
assert !enableIntegerSimple -> gmp != null;
let
inherit (bootPkgs) ghc;
# TODO(@Ericson2314) Make unconditional
prefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
docFixes = fetchurl {
url = "https://downloads.haskell.org/~ghc/7.10.3/ghc-7.10.3a.patch";
sha256 = "1j45z4kcd3w1rzm4hapap2xc16bbh942qnzzdbdjcwqznsccznf0";
@ -18,7 +32,7 @@ in
stdenv.mkDerivation rec {
version = "7.10.3";
name = "ghc-${version}";
name = "${prefix}ghc-${version}";
src = fetchurl {
url = "https://downloads.haskell.org/~ghc/${version}/${name}-src.tar.xz";
@ -62,7 +76,7 @@ stdenv.mkDerivation rec {
postInstall = ''
# Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${prefix}ghc
# Patch scripts to include "readelf" and "cat" in $PATH.
for i in "$out/bin/"*; do
@ -73,7 +87,7 @@ stdenv.mkDerivation rec {
'';
passthru = {
inherit bootPkgs;
inherit bootPkgs prefix;
};
meta = {

@ -2,9 +2,12 @@
# If enabled GHC will be build with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp
, enableIntegerSimple ? false, gmp ? null
}:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec {
version = "7.2.2";
name = "ghc-${version}";
@ -51,6 +54,8 @@ stdenv.mkDerivation rec {
# that in turn causes GHCi to abort
stripDebugFlags=["-S" "--keep-file-symbols"];
passthru = { prefix = ""; };
meta = {
homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler";

@ -1,32 +1,35 @@
{stdenv, fetchurl, perl, ncurses5, gmp, libiconv, makeWrapper}:
{ stdenv
, fetchurl, perl, makeWrapper
, ncurses5, gmp, libiconv
}:
# Prebuilt only does native
assert stdenv.targetPlatform == stdenv.hostPlatform;
stdenv.mkDerivation rec {
version = "7.4.2";
name = "ghc-${version}-binary";
src =
if stdenv.system == "i686-linux" then
fetchurl {
src = {
"i686-linux" = fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux.tar.bz2";
sha256 = "0gny7knhss0w0d9r6jm1gghrcb8kqjvj94bb7hxf9syrk4fxlcxi";
}
else if stdenv.system == "x86_64-linux" then
fetchurl {
};
"x86_64-linux" = fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux.tar.bz2";
sha256 = "043jabd0lh6n1zlqhysngbpvlsdznsa2mmsj08jyqgahw9sjb5ns";
}
else if stdenv.system == "i686-darwin" then
fetchurl {
};
"i686-darwin" = fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-apple-darwin.tar.bz2";
sha256 = "1vrbs3pzki37hzym1f1nh07lrqh066z3ypvm81fwlikfsvk4djc0";
}
else if stdenv.system == "x86_64-darwin" then
fetchurl {
};
"x86_64-darwin" = fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.bz2";
sha256 = "1imzqc0slpg0r6p40n5a9m18cbcm0m86z8dgyhfxcckksw54mzwf";
}
else throw "cannot bootstrap GHC on this platform";
};
}.${stdenv.hostPlatform.system}
or (throw "cannot bootstrap GHC on this platform");
buildInputs = [perl];

@ -1,10 +1,14 @@
{ stdenv, fetchurl, ghc, perl, ncurses, libiconv
# If enabled GHC will be build with the GPL-free but slower integer-simple
, # If enabled GHC will be build with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp
enableIntegerSimple ? false, gmp ? null
}:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
assert !enableIntegerSimple -> gmp != null;
stdenv.mkDerivation rec {
version = "7.4.2";
@ -52,6 +56,8 @@ stdenv.mkDerivation rec {
# that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
passthru = { prefix = ""; };
meta = {
homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler";

@ -1,10 +1,14 @@
{ stdenv, fetchurl, ghc, perl, ncurses, binutils, libiconv
# If enabled GHC will be build with the GPL-free but slower integer-simple
, # If enabled GHC will be build with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp
enableIntegerSimple ? false, gmp ? null
}:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
assert !enableIntegerSimple -> gmp != null;
let
# The "-Wa,--noexecstack" options might be needed only with GNU ld (as opposed
# to the gold linker). It prevents binaries' stacks from being marked as
@ -78,6 +82,8 @@ in stdenv.mkDerivation rec {
# that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
passthru = { prefix = ""; };
meta = {
homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler";

@ -1,10 +1,14 @@
{ stdenv, fetchurl, ghc, perl, ncurses, libiconv
# If enabled GHC will be build with the GPL-free but slower integer-simple
, # If enabled GHC will be build with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp
enableIntegerSimple ? false, gmp ? null
}:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
assert !enableIntegerSimple -> gmp != null;
stdenv.mkDerivation rec {
version = "7.8.3";
name = "ghc-${version}";
@ -49,6 +53,8 @@ stdenv.mkDerivation rec {
# that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
passthru = { prefix = ""; };
meta = {
homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler";

@ -1,10 +1,14 @@
{ stdenv, fetchurl, ghc, perl, ncurses, libiconv
# If enabled GHC will be build with the GPL-free but slower integer-simple
, # If enabled GHC will be build with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp
enableIntegerSimple ? false, gmp ? null
}:
# TODO(@Ericson2314): Cross compilation support
assert stdenv.targetPlatform == stdenv.hostPlatform;
assert !enableIntegerSimple -> gmp != null;
stdenv.mkDerivation (rec {
version = "7.8.4";
name = "ghc-${version}";
@ -49,6 +53,8 @@ stdenv.mkDerivation (rec {
# that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
passthru = { prefix = ""; };
meta = {
homepage = http://haskell.org/ghc;
description = "The Glasgow Haskell Compiler";

@ -1,18 +1,30 @@
{ stdenv, lib, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
, hscolour, patchutils, sphinx
{ stdenv, __targetPackages
, buildPlatform, hostPlatform, targetPlatform
# If enabled GHC will be build with the GPL-free but slower integer-simple
# build-tools
, bootPkgs, hscolour
, binutils, coreutils, fetchurl, fetchpatch, patchutils, perl, sphinx
, libiconv, ncurses
, # If enabled GHC will be build with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp
, cross ? null
enableIntegerSimple ? false, gmp ? null
}:
assert !enableIntegerSimple -> gmp != null;
let
inherit (bootPkgs) ghc;
# TODO(@Ericson2314) Make unconditional
prefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
in
stdenv.mkDerivation rec {
version = "8.0.2";
name = "ghc-${version}";
name = "${prefix}ghc-${version}";
src = fetchurl {
url = "https://downloads.haskell.org/~ghc/8.0.2/${name}-src.tar.xz";
@ -47,19 +59,20 @@ stdenv.mkDerivation rec {
"--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib"
] ++ stdenv.lib.optional stdenv.isDarwin [
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
] ++
] ++ stdenv.lib.optionals (targetPlatform.isDarwin && targetPlatform.isAarch64) [
# fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
"--disable-large-address-space"
];
# required, because otherwise all symbols from HSffi.o are stripped, and
# that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
postInstall = ''
paxmark m $out/lib/${name}/bin/{ghc,haddock}
paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"}
# Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${prefix}ghc
# Patch scripts to include "readelf" and "cat" in $PATH.
for i in "$out/bin/"*; do
@ -70,7 +83,7 @@ stdenv.mkDerivation rec {
'';
passthru = {
inherit bootPkgs;
inherit bootPkgs prefix;
};
meta = {

@ -1,16 +1,30 @@
{ stdenv, lib, fetchurl, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
, autoconf, automake, happy, alex, python3, sphinx, hscolour
, buildPlatform, targetPlatform , selfPkgs, cross ? null
{ stdenv, __targetPackages
, buildPlatform, hostPlatform, targetPlatform
, selfPkgs, cross ? null
# If enabled GHC will be build with the GPL-free but slower integer-simple
# build-tools
, bootPkgs, alex, happy, hscolour
, autoconf, automake, binutils, coreutils, fetchurl, perl, python3, sphinx
, libiconv ? null, ncurses
, # If enabled, GHC will be build with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp
enableIntegerSimple ? false, gmp ? null
}:
assert !enableIntegerSimple -> gmp != null;
let
inherit (bootPkgs) ghc;
version = "8.2.1";
# TODO(@Ericson2314) Make unconditional
prefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
commonBuildInputs = [ alex autoconf automake ghc happy hscolour perl python3 sphinx ];
commonPreConfigure = ''
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
@ -21,9 +35,10 @@ let
'' + stdenv.lib.optionalString enableIntegerSimple ''
echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk
'';
in stdenv.mkDerivation (rec {
in
stdenv.mkDerivation (rec {
inherit version;
name = "ghc-${version}";
name = "${prefix}ghc-${version}";
src = fetchurl {
url = "https://downloads.haskell.org/~ghc/${version}/${name}-src.tar.xz";
@ -52,15 +67,17 @@ in stdenv.mkDerivation (rec {
# required, because otherwise all symbols from HSffi.o are stripped, and
# that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
checkTarget = "test";
# zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't
# treat that as a unary `{x,y,z,..}` repetition.
postInstall = ''
paxmark m $out/lib/${name}/bin/{ghc,haddock}
paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"}
# Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${prefix}ghc
# Patch scripts to include "readelf" and "cat" in $PATH.
for i in "$out/bin/"*; do
@ -73,7 +90,7 @@ in stdenv.mkDerivation (rec {
outputs = [ "out" "doc" ];
passthru = {
inherit bootPkgs;
inherit bootPkgs prefix;
} // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) {
crossCompiler = selfPkgs.ghc.override {
cross = targetPlatform;
@ -105,7 +122,7 @@ in stdenv.mkDerivation (rec {
"--enable-bootstrap-with-devel-snapshot"
] ++
# fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
stdenv.lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutils ];

@ -1,20 +1,33 @@
{ stdenv, lib, fetchgit, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
, autoconf, automake, happy, alex, python3, buildPlatform, targetPlatform
{ stdenv, __targetPackages
, buildPlatform, hostPlatform, targetPlatform
, selfPkgs, cross ? null
# If enabled GHC will be build with the GPL-free but slower integer-simple
# build-tools
, bootPkgs, alex, happy
, autoconf, automake, binutils, coreutils, fetchgit, perl, python3
, libiconv ? null, ncurses
, # If enabled, GHC will be build with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library.
, enableIntegerSimple ? false, gmp
enableIntegerSimple ? false, gmp ? null
, version ? "8.3.20170808"
}:
assert !enableIntegerSimple -> gmp != null;
let
inherit (bootPkgs) ghc;
commonBuildInputs = [ ghc perl autoconf automake happy alex python3 ];
rev = "14457cf6a50f708eecece8f286f08687791d51f7";
# TODO(@Ericson2314) Make unconditional
prefix = stdenv.lib.optionalString
(targetPlatform != hostPlatform)
"${targetPlatform.config}-";
commonBuildInputs = [ ghc perl autoconf automake happy alex python3 ];
commonPreConfigure = ''
echo ${version} >VERSION
echo ${rev} >GIT_COMMIT_ID
@ -27,7 +40,8 @@ let
'' + stdenv.lib.optionalString enableIntegerSimple ''
echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk
'';
in stdenv.mkDerivation (rec {
in
stdenv.mkDerivation (rec {
inherit version rev;
name = "ghc-${version}";
@ -57,15 +71,17 @@ in stdenv.mkDerivation (rec {
# required, because otherwise all symbols from HSffi.o are stripped, and
# that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols";
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
checkTarget = "test";
# zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't
# treat that as a unary `{x,y,z,..}` repetition.
postInstall = ''
paxmark m $out/lib/${name}/bin/{ghc,haddock}
paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"}
# Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/ghc
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${prefix}ghc
# Patch scripts to include "readelf" and "cat" in $PATH.
for i in "$out/bin/"*; do
@ -78,7 +94,7 @@ in stdenv.mkDerivation (rec {
outputs = [ "out" "doc" ];
passthru = {
inherit bootPkgs;
inherit bootPkgs prefix;
} // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) {
crossCompiler = selfPkgs.ghc.override {
cross = targetPlatform;
@ -110,7 +126,7 @@ in stdenv.mkDerivation (rec {
"--enable-bootstrap-with-devel-snapshot"
] ++
# fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
stdenv.lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
buildInputs = commonBuildInputs;

@ -1,7 +1,14 @@
{ stdenv, fetchurl, ghc, pkgconfig, glibcLocales, coreutils, gnugrep, gnused
, jailbreak-cabal, hscolour, cpphs, nodejs, lib, removeReferencesTo
{ stdenv, buildPackages, ghc
, jailbreak-cabal, hscolour, cpphs, nodejs
, buildPlatform, hostPlatform
}:
let isCross = (ghc.cross or null) != null; in
let
isCross = buildPlatform != hostPlatform;
inherit (buildPackages)
fetchurl removeReferencesTo
pkgconfig binutils coreutils gnugrep gnused glibcLocales;
in
{ pname
, dontStrip ? (ghc.isGhcjs or false)
@ -20,8 +27,8 @@ let isCross = (ghc.cross or null) != null; in
, enableLibraryProfiling ? false
, enableExecutableProfiling ? false
# TODO enable shared libs for cross-compiling
, enableSharedExecutables ? !isCross && (((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version))
, enableSharedLibraries ? !isCross && (((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version))
, enableSharedExecutables ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
, enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
, enableSplitObjs ? null # OBSOLETE, use enableDeadCodeElimination
, enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin
, enableStaticLibraries ? true
@ -53,7 +60,7 @@ let isCross = (ghc.cross or null) != null; in
, shellHook ? ""
, coreSetup ? false # Use only core packages to build Setup.hs.
, useCpphs ? false
, hardeningDisable ? lib.optional (ghc.isHaLVM or false) "all"
, hardeningDisable ? stdenv.lib.optional (ghc.isHaLVM or false) "all"
, enableSeparateDataOutput ? false
, enableSeparateDocOutput ? doHaddock
} @ args:
@ -102,11 +109,12 @@ let
enableParallelBuilding = (versionOlder "7.8" ghc.version && !hasActiveLibrary) || versionOlder "8.0.1" ghc.version;
crossCabalFlags = [
"--with-ghc=${ghc.cross.config}-ghc"
"--with-ghc-pkg=${ghc.cross.config}-ghc-pkg"
"--with-gcc=${ghc.cc}"
"--with-ld=${ghc.ld}"
"--with-ghc=${ghc.prefix}ghc"
"--with-ghc-pkg=${ghc.prefix}ghc-pkg"
"--with-gcc=${ghc.prefix}cc"
"--with-ld=${ghc.prefix}ld"
"--with-hsc2hs=${nativeGhc}/bin/hsc2hs"
"--with-strip=${binutils}/bin/${ghc.prefix}strip"
] ++ (if isHaLVM then [] else ["--hsc2hs-options=--cross-compile"]);
crossCabalFlagsString =
@ -135,7 +143,7 @@ let
] ++ optionals isGhcjs [
"--ghcjs"
] ++ optionals isCross ([
"--configure-option=--host=${ghc.cross.config}"
"--configure-option=--host=${hostPlatform.config}"
] ++ crossCabalFlags);
setupCompileFlags = [
@ -170,8 +178,7 @@ let
setupBuilder = if isCross then "${nativeGhc}/bin/ghc" else ghcCommand;
setupCommand = "./Setup";
ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
crossPrefix = if (ghc.cross or null) != null then "${ghc.cross.config}-" else "";
ghcCommand = "${crossPrefix}${ghcCommand'}";
ghcCommand = "${ghc.prefix}${ghcCommand'}";
ghcCommandCaps= toUpper ghcCommand';
in
@ -268,6 +275,8 @@ stdenv.mkDerivation ({
runHook postCompileBuildDriver
'';
inherit configureFlags;
configurePhase = ''
runHook preConfigure
@ -393,7 +402,6 @@ stdenv.mkDerivation ({
// optionalAttrs (postCompileBuildDriver != "") { inherit postCompileBuildDriver; }
// optionalAttrs (preUnpack != "") { inherit preUnpack; }
// optionalAttrs (postUnpack != "") { inherit postUnpack; }
// optionalAttrs (configureFlags != []) { inherit configureFlags; }
// optionalAttrs (patches != []) { inherit patches; }
// optionalAttrs (patchPhase != "") { inherit patchPhase; }
// optionalAttrs (preConfigure != "") { inherit preConfigure; }
@ -412,5 +420,5 @@ stdenv.mkDerivation ({
// optionalAttrs (postFixup != "") { inherit postFixup; }
// optionalAttrs (dontStrip) { inherit dontStrip; }
// optionalAttrs (hardeningDisable != []) { inherit hardeningDisable; }
// optionalAttrs (stdenv.isLinux) { LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; }
// optionalAttrs (buildPlatform.isLinux){ LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; }
)

@ -1,7 +1,10 @@
# This expression takes a file like `hackage-packages.nix` and constructs
# a full package set out of that.
{ # package-set used for non-haskell dependencies (all of nixpkgs)
{ # package-set used for build tools (all of nixpkgs)
buildPackages
, # package-set used for non-haskell dependencies (all of nixpkgs)
pkgs
, # stdenv to use for building haskell packages
@ -28,19 +31,21 @@
self:
let
inherit (stdenv) buildPlatform hostPlatform;
inherit (stdenv.lib) fix' extends makeOverridable;
inherit (haskellLib) overrideCabal;
buildHaskellPackages = if hostPlatform != buildPlatform
then self.ghc.bootPkgs
else self;
mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
inherit stdenv;
inherit (pkgs) fetchurl pkgconfig glibcLocales coreutils gnugrep gnused;
nodejs = pkgs.nodejs-slim;
jailbreak-cabal = if (self.ghc.cross or null) != null
then self.ghc.bootPkgs.jailbreak-cabal
else self.jailbreak-cabal;
nodejs = buildPackages.nodejs-slim;
inherit (buildHaskellPackages) jailbreak-cabal;
inherit (self) ghc;
hscolour = overrideCabal self.hscolour (drv: {
hscolour = overrideCabal buildHaskellPackages.hscolour (drv: {
isLibrary = false;
doHaddock = false;
hyperlinkSource = false; # Avoid depending on hscolour for this build.
@ -104,13 +109,13 @@ let
haskellSrc2nix = { name, src, sha256 ? null }:
let
sha256Arg = if isNull sha256 then "--sha256=" else ''--sha256="${sha256}"'';
in pkgs.stdenv.mkDerivation {
in pkgs.buildPackages.stdenv.mkDerivation {
name = "cabal2nix-${name}";
buildInputs = [ pkgs.haskellPackages.cabal2nix ];
nativeBuildInputs = [ pkgs.buildPackages.haskellPackages.cabal2nix ];
preferLocalBuild = true;
phases = ["installPhase"];
LANG = "en_US.UTF-8";
LOCALE_ARCHIVE = pkgs.lib.optionalString pkgs.stdenv.isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive";
LOCALE_ARCHIVE = pkgs.lib.optionalString buildPlatform.isLinux "${buildPackages.glibcLocales}/lib/locale/locale-archive";
installPhase = ''
export HOME="$TMP"
mkdir -p "$out"

@ -36,9 +36,8 @@ let
isHaLVM = ghc.isHaLVM or false;
ghc761OrLater = isGhcjs || isHaLVM || lib.versionOlder "7.6.1" ghc.version;
packageDBFlag = if ghc761OrLater then "--global-package-db" else "--global-conf";
ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
crossPrefix = if (ghc.cross or null) != null then "${ghc.cross.config}-" else "";
ghcCommand = "${crossPrefix}${ghcCommand'}";
ghcCommand' = if isGhcjs then "ghcjs" else "ghc";
ghcCommand = "${ghc.prefix}${ghcCommand'}";
ghcCommandCaps= lib.toUpper ghcCommand';
libDir = if isHaLVM then "$out/lib/HaLVM-${ghc.version}" else "$out/lib/${ghcCommand}-${ghc.version}";
docDir = "$out/share/doc/ghc/html";

@ -2,8 +2,7 @@
{ haskellPackages, src, deps ? p : [], name }: let
inherit (haskellPackages) ghc ghcWithPackages;
with-env = ghcWithPackages deps;
crossPrefix = if (ghc.cross or null) != null then "${ghc.cross.config}-" else "";
ghcName = "${crossPrefix}ghc";
ghcName = "${ghc.prefix}ghc";
in runCommand name { buildInputs = [ with-env cctools ]; } ''
mkdir -p $out/lib
mkdir -p $out/include