[Nix-dev] GHC 7.8.2-binary.nix to bootstrap GHC HEAD
Mateusz Kowalczyk
fuuzetsu at fuuzetsu.co.uk
Sat May 3 07:15:52 CEST 2014
Amongst my struggles to get recent GHC HEAD snapshots to work on NixOS,
I noticed that GHC 7.4.2 is used to bootstrap it. Perhaps that's what's
causing the problems[1] so my current goal is to make a binary install
of GHC 7.8.2 work. To be clear, I want to be able to install the GHC
7.8.2 binary provided by the GHC team, which I can then hopefully use to
bootstrap HEAD.
I added
ghc782Binary = lowPrio (callPackage
../development/compilers/ghc/7.8.2-binary.nix {
gmp = pkgs.gmp;
});
to haskell-defaults.nix and set ‘ghcBinary = ghc782Binary; in the same
file for ghcHEAD.
I had then copied + pasted the most recent binary package, that is 7.4.2
and renamed it appropriately. I fixed the download links and hashes.
First problem was some /bin/bash paths. I fix those with shebang fix.
Second problem was libgcc_s.so not being found. I change LD_LIBRARY_PATH
in configurePhase to accommodate for this.
It now goes to the install phase but in the end fails with:
/nix/store/451gmdjnzl3pwvgclrhyqb3znfg3mzi1-ghc-7.8.2-binary/lib/ghc-7.8.2/bin/ghc-pkg:
error while loading shared libraries: libHSterminfo-0.4.0.0-ghc7.8.2.so:
cannot open shared object file: No such file or directory
I can confirm that all those libraries are in the stored under
lib/ghc-7.8.2/<libraryname> but the copied binaries seem to have no idea
about them. IN fact, everything in lib/ghc-7.8.2/bin has no idea about
where its libraries are:
[shana at lenalee:~/programming/haddock]$ ldd
/nix/store/451gmdjnzl3pwvgclrhyqb3znfg3mzi1-ghc-7.8.2-binary/lib/ghc-7.8.2/bin/ghc-pkg
linux-gate.so.1 (0xb7736000)
libHSterminfo-0.4.0.0-ghc7.8.2.so => not found
libHSbin-package-db-0.0.0.0-ghc7.8.2.so => not found
libHSbinary-0.7.1.0-ghc7.8.2.so => not found
libHSCabal-1.18.1.3-ghc7.8.2.so => not found
libHSprocess-1.2.0.0-ghc7.8.2.so => not found
libHSpretty-1.1.1.1-ghc7.8.2.so => not found
libHSdirectory-1.2.1.0-ghc7.8.2.so => not found
libHSunix-2.7.0.1-ghc7.8.2.so => not found
libHStime-1.4.2-ghc7.8.2.so => not found
libHSold-locale-1.0.0.6-ghc7.8.2.so => not found
libHSfilepath-1.3.0.2-ghc7.8.2.so => not found
libHScontainers-0.5.5.1-ghc7.8.2.so => not found
libHSbytestring-0.10.4.0-ghc7.8.2.so => not found
libHSdeepseq-1.3.0.2-ghc7.8.2.so => not found
libHSarray-0.5.0.0-ghc7.8.2.so => not found
libHSbase-4.7.0.0-ghc7.8.2.so => not found
libHSinteger-gmp-0.5.1.0-ghc7.8.2.so => not found
libHSghc-prim-0.3.1.0-ghc7.8.2.so => not found
libHSrts-ghc7.8.2.so => not found
libffi.so.6 => not found
libtinfo.so.5 => not found
librt.so.1 =>
/nix/store/4v0a2fncxsk2f57jixq7i59k6hdl34fx-glibc-2.19/lib/librt.so.1
(0xb7728000)
libutil.so.1 =>
/nix/store/4v0a2fncxsk2f57jixq7i59k6hdl34fx-glibc-2.19/lib/libutil.so.1
(0xb7723000)
libdl.so.2 =>
/nix/store/4v0a2fncxsk2f57jixq7i59k6hdl34fx-glibc-2.19/lib/libdl.so.2
(0xb771f000)
libgmp.so.10 =>
/nix/store/qnkyas42nf0knps3va30y29y3zvmgy2v-gmp-5.1.3/lib/libgmp.so.10
(0xb769d000)
libm.so.6 =>
/nix/store/4v0a2fncxsk2f57jixq7i59k6hdl34fx-glibc-2.19/lib/libm.so.6
(0xb765c000)
libc.so.6 =>
/nix/store/4v0a2fncxsk2f57jixq7i59k6hdl34fx-glibc-2.19/lib/libc.so.6
(0xb74c7000)
libpthread.so.0 =>
/nix/store/4v0a2fncxsk2f57jixq7i59k6hdl34fx-glibc-2.19/lib/libpthread.so.0
(0xb74ad000)
/nix/store/4v0a2fncxsk2f57jixq7i59k6hdl34fx-glibc-2.19/lib/ld-linux.so.2
(0xb7737000)
I am now stuck here, I don't know how to get the binaries to see the
libraries properly. All this happens during the installPhase (left
default) step, copying the libs followed by whatever it is the binaries
are meant to be doing. The next thing that comes to mind is to gut GHC's
install phase to let me patchelf the binaries after copying the
libraries, but that doesn't sound pretty. Perhaps I am simply doing
something very wrong, or the nix code from 7.4.2 messes something up.
I am attaching the two relevant files. Any input *very* welcome.
[1]: https://github.com/NixOS/nixpkgs/issues/2428
--
Mateusz K.
-------------- next part --------------
# Haskell / GHC infrastructure in Nixpkgs
#
# In this file, we
#
# * define sets of default package versions for each GHC compiler version,
# * associate GHC versions with bootstrap compiler versions and package defaults.
#
# The actual Haskell packages are composed in haskell-packages.nix. There is
# more documentation in there.
{ makeOverridable, lowPrio, stdenv, pkgs, newScope, config, callPackage } : rec {
# Preferences functions.
#
# Change these if you want to change the default versions of packages being used
# for a particular GHC version.
ghcHEADPrefs =
self : self.haskellPlatformArgs_future self // {
haskellPlatform = null;
extensibleExceptions = self.extensibleExceptions_0_1_1_4;
cabalInstall_1_18_0_3 = self.cabalInstall_1_18_0_3.override { Cabal = null; };
cabalInstall = self.cabalInstall_1_18_0_3.override { Cabal = null; };
# HTTP = self.HTTP_4000_2_13;
};
ghc782Prefs =
self : self.haskellPlatformArgs_future self // {
haskellPlatform = null;
extensibleExceptions = self.extensibleExceptions_0_1_1_4;
cabalInstall_1_18_0_3 = self.cabalInstall_1_18_0_3.override { Cabal = null; };
cabalInstall = self.cabalInstall_1_18_0_3.override { Cabal = null; };
binary_0_7_1_0 = null;
};
ghc763Prefs =
self : self.haskellPlatformArgs_2013_2_0_0 self // {
haskellPlatform = self.haskellPlatform_2013_2_0_0;
extensibleExceptions = self.extensibleExceptions_0_1_1_4;
};
ghc742Prefs =
self : self.haskellPlatformArgs_2012_4_0_0 self // {
haskellPlatform = self.haskellPlatform_2012_4_0_0;
cabalInstall_1_16_0_2 = self.cabalInstall_1_16_0_2.override { Cabal = self.Cabal_1_16_0_3; };
cabal2nix = self.cabal2nix.override { Cabal = self.Cabal_1_16_0_3; hackageDb = self.hackageDb.override { Cabal = self.Cabal_1_16_0_3; }; };
haskeline = self.haskeline_0_7_1_1;
terminfo = self.terminfo_0_3_2_6;
};
ghc741Prefs =
self : self.haskellPlatformArgs_2012_2_0_0 self // {
haskellPlatform = self.haskellPlatform_2012_2_0_0;
cabalInstall_1_16_0_2 = self.cabalInstall_1_16_0_2.override { Cabal = self.Cabal_1_16_0_3; };
cabal2nix = self.cabal2nix.override { Cabal = self.Cabal_1_16_0_3; hackageDb = self.hackageDb.override { Cabal = self.Cabal_1_16_0_3; }; };
haskeline = self.haskeline_0_7_1_1;
terminfo = self.terminfo_0_3_2_6;
};
ghc722Prefs =
self : self.haskellPlatformArgs_2012_2_0_0 self // {
haskellPlatform = self.haskellPlatform_2012_2_0_0;
deepseq = self.deepseq_1_3_0_2;
cabalInstall_0_14_0 = self.cabalInstall_0_14_0.override { Cabal = self.Cabal_1_14_0; };
cabalInstall_1_16_0_2 = self.cabalInstall_1_16_0_2.override { Cabal = self.Cabal_1_16_0_3; };
cabalInstall = self.cabalInstall_0_14_0.override { Cabal = self.Cabal_1_14_0; };
cabal2nix = self.cabal2nix.override { Cabal = self.Cabal_1_16_0_3; hackageDb = self.hackageDb.override { Cabal = self.Cabal_1_16_0_3; }; };
binary = self.binary_0_6_0_0;
prettyShow = self.prettyShow_1_2;
quickcheckIo = self.quickcheckIo.override {
HUnit = self.HUnit_1_2_5_2;
QuickCheck = self.QuickCheck2;
};
hspecExpectations = self.hspecExpectations.override {
HUnit = self.HUnit_1_2_5_2;
};
haskeline = self.haskeline_0_7_1_1;
terminfo = self.terminfo_0_3_2_6;
};
ghc721Prefs = ghc722Prefs;
ghc704Prefs =
self : self.haskellPlatformArgs_2011_4_0_0 self // {
haskellPlatform = self.haskellPlatform_2011_4_0_0;
cabalInstall_0_14_0 = self.cabalInstall_0_14_0.override { Cabal = self.Cabal_1_14_0; };
cabalInstall_1_16_0_2 = self.cabalInstall_1_16_0_2.override { Cabal = self.Cabal_1_16_0_3; };
monadPar = self.monadPar_0_1_0_3;
jailbreakCabal = self.jailbreakCabal.override { Cabal = self.disableTest self.Cabal_1_14_0; };
cabal2nix = self.cabal2nix.override { Cabal = self.Cabal_1_16_0_3; hackageDb = self.hackageDb.override { Cabal = self.Cabal_1_16_0_3; }; };
prettyShow = self.prettyShow_1_2;
binary = self.binary_0_6_0_0;
Cabal_1_18_1_3 = self.Cabal_1_18_1_3.override { deepseq = self.deepseq_1_3_0_2; };
quickcheckIo = self.quickcheckIo.override {
HUnit = self.HUnit_1_2_5_2;
QuickCheck = self.QuickCheck2;
};
hspecExpectations = self.hspecExpectations.override {
HUnit = self.HUnit_1_2_5_2;
};
haskeline = self.haskeline_0_7_1_1;
terminfo = self.terminfo_0_3_2_6;
};
ghc703Prefs =
self : self.haskellPlatformArgs_2011_2_0_1 self // {
haskellPlatform = self.haskellPlatform_2011_2_0_1;
cabalInstall_0_14_0 = self.cabalInstall_0_14_0.override { Cabal = self.Cabal_1_14_0; zlib = self.zlib_0_5_3_3; };
cabalInstall_1_16_0_2 = self.cabalInstall_1_16_0_2.override { Cabal = self.Cabal_1_16_0_3; zlib = self.zlib_0_5_3_3; };
monadPar = self.monadPar_0_1_0_3;
jailbreakCabal = self.jailbreakCabal.override { Cabal = self.disableTest self.Cabal_1_14_0; };
cabal2nix = self.cabal2nix.override { Cabal = self.Cabal_1_16_0_3; hackageDb = self.hackageDb.override { Cabal = self.Cabal_1_16_0_3; }; };
prettyShow = self.prettyShow_1_2;
binary = self.binary_0_6_0_0;
Cabal_1_18_1_3 = self.Cabal_1_18_1_3.override { deepseq = self.deepseq_1_3_0_2; };
quickcheckIo = self.quickcheckIo.override {
HUnit = self.HUnit_1_2_5_2;
QuickCheck = self.QuickCheck2;
};
hspecExpectations = self.hspecExpectations.override {
HUnit = self.HUnit_1_2_5_2;
};
haskeline = self.haskeline_0_7_1_1;
terminfo = self.terminfo_0_3_2_6;
};
ghc702Prefs = ghc701Prefs;
ghc701Prefs =
self : self.haskellPlatformArgs_2011_2_0_0 self // {
haskellPlatform = self.haskellPlatform_2011_2_0_0;
cabalInstall_0_14_0 = self.cabalInstall_0_14_0.override { Cabal = self.Cabal_1_14_0; zlib = self.zlib_0_5_3_3; };
cabalInstall_1_16_0_2 = self.cabalInstall_1_16_0_2.override { Cabal = self.Cabal_1_16_0_3; zlib = self.zlib_0_5_3_3; };
monadPar = self.monadPar_0_1_0_3;
jailbreakCabal = self.jailbreakCabal.override { Cabal = self.disableTest self.Cabal_1_14_0; };
cabal2nix = self.cabal2nix.override { Cabal = self.Cabal_1_16_0_3; hackageDb = self.hackageDb.override { Cabal = self.Cabal_1_16_0_3; }; };
prettyShow = self.prettyShow_1_2;
binary = self.binary_0_6_0_0;
Cabal_1_18_1_3 = self.Cabal_1_18_1_3.override { deepseq = self.deepseq_1_3_0_2; };
quickcheckIo = self.quickcheckIo.override {
HUnit = self.HUnit_1_2_5_2;
QuickCheck = self.QuickCheck2;
};
hspecExpectations = self.hspecExpectations.override {
HUnit = self.HUnit_1_2_5_2;
};
haskeline = self.haskeline_0_7_1_1;
terminfo = self.terminfo_0_3_2_6;
};
ghc6123Prefs = ghc6122Prefs;
ghc6122Prefs =
self : self.haskellPlatformArgs_2010_2_0_0 self // {
haskellPlatform = self.haskellPlatform_2010_2_0_0;
mtl1 = self.mtl_1_1_0_2;
monadPar = self.monadPar_0_1_0_3;
deepseq = self.deepseq_1_1_0_2;
# deviating from Haskell platform here, to make some packages (notably statistics) compile
jailbreakCabal = self.jailbreakCabal.override { Cabal = self.disableTest self.Cabal_1_14_0; };
cabal2nix = self.cabal2nix.override { Cabal = self.Cabal_1_16_0_3; hackageDb = self.hackageDb.override { Cabal = self.Cabal_1_16_0_3; }; };
binary = self.binary_0_6_0_0;
cabalInstall_1_16_0_2 = self.cabalInstall_1_16_0_2.override {
Cabal = self.Cabal_1_16_0_3; zlib = self.zlib_0_5_3_3;
mtl = self.mtl_2_1_2;
HTTP = self.HTTP_4000_1_1.override { mtl = self.mtl_2_1_2; };
};
quickcheckIo = self.quickcheckIo.override {
HUnit = self.HUnit_1_2_5_2;
QuickCheck = self.QuickCheck2;
};
hspecExpectations = self.hspecExpectations.override {
HUnit = self.HUnit_1_2_5_2;
};
haskeline = self.haskeline_0_7_1_1;
terminfo = self.terminfo_0_3_2_6;
};
ghc6121Prefs =
self : self.haskellPlatformArgs_2010_1_0_0 self // {
haskellPlatform = self.haskellPlatform_2010_1_0_0;
mtl1 = self.mtl_1_1_0_2;
extensibleExceptions = self.extensibleExceptions_0_1_1_0;
deepseq = self.deepseq_1_1_0_2;
monadPar = self.monadPar_0_1_0_3;
# deviating from Haskell platform here, to make some packages (notably statistics) compile
jailbreakCabal = self.jailbreakCabal.override { Cabal = self.disableTest self.Cabal_1_14_0; };
cabal2nix = self.cabal2nix.override { Cabal = self.Cabal_1_16_0_3; hackageDb = self.hackageDb.override { Cabal = self.Cabal_1_16_0_3; }; };
binary = self.binary_0_6_0_0;
cabalInstall_1_16_0_2 = self.cabalInstall_1_16_0_2.override {
Cabal = self.Cabal_1_16_0_3;
zlib = self.zlib_0_5_3_3;
mtl = self.mtl_2_1_2;
HTTP = self.HTTP_4000_1_1.override { mtl = self.mtl_2_1_2; };
};
quickcheckIo = self.quickcheckIo.override {
HUnit = self.HUnit_1_2_5_2;
QuickCheck = self.QuickCheck2;
};
hspecExpectations = self.hspecExpectations.override {
HUnit = self.HUnit_1_2_5_2;
};
haskeline = self.haskeline_0_7_1_1;
terminfo = self.terminfo_0_3_2_6;
};
ghc6104Prefs =
self : self.haskellPlatformArgs_2009_2_0_2 self // {
haskellPlatform = self.haskellPlatform_2009_2_0_2;
mtl = self.mtl_1_1_0_2;
mtl1 = self.mtl_1_1_0_2;
extensibleExceptions = self.extensibleExceptions_0_1_1_0;
text = self.text_0_11_0_6;
deepseq = self.deepseq_1_1_0_2;
monadPar = self.monadPar_0_1_0_3;
# deviating from Haskell platform here, to make some packages (notably statistics) compile
jailbreakCabal = self.jailbreakCabal.override { Cabal = self.disableTest self.Cabal_1_14_0; };
binary = self.binary_0_6_0_0;
cabalInstall_1_16_0_2 = self.cabalInstall_1_16_0_2.override {
Cabal = self.Cabal_1_16_0_3;
zlib = self.zlib_0_5_3_3;
mtl = self.mtl_2_1_2;
HTTP = self.HTTP_4000_1_1.override { mtl = self.mtl_2_1_2; };
};
haskeline = self.haskeline_0_7_1_1;
terminfo = self.terminfo_0_3_2_6;
};
# Abstraction for Haskell packages collections
packagesFun = makeOverridable
({ ghcPath
, ghcBinary ? ghc6101Binary
, prefFun
, extraPrefs ? (x : {})
, profExplicit ? false, profDefault ? false
, modifyPrio ? lowPrio
, extraArgs ? {}
} :
import ./haskell-packages.nix {
inherit pkgs newScope modifyPrio;
prefFun = self : super : self // prefFun super // extraPrefs super;
# prefFun = self : super : self;
enableLibraryProfiling =
if profExplicit then profDefault
else config.cabal.libraryProfiling or profDefault;
ghc = callPackage ghcPath ({ ghc = ghcBinary; } // extraArgs);
});
defaultVersionPrioFun =
profDefault :
if config.cabal.libraryProfiling or false == profDefault
then (x : x)
else lowPrio;
packages = args : let r = packagesFun args;
in r // { lowPrio = r.override { modifyPrio = lowPrio; };
highPrio = r.override { modifyPrio = x : x; };
noProfiling = r.override { profDefault = false;
profExplicit = true;
modifyPrio = defaultVersionPrioFun false; };
profiling = r.override { profDefault = true;
profExplicit = true;
modifyPrio = defaultVersionPrioFun true; };
};
# Binary versions of GHC
#
# GHC binaries are around for bootstrapping purposes
# If we'd want to reactivate the 6.6 and 6.8 series of ghc, we'd
# need to reenable an old binary such as this.
/*
ghc642Binary = lowPrio (import ../development/compilers/ghc/6.4.2-binary.nix {
inherit fetchurl stdenv ncurses gmp;
readline = if stdenv.system == "i686-linux" then readline4 else readline5;
perl = perl58;
});
*/
ghc6101Binary = lowPrio (callPackage ../development/compilers/ghc/6.10.1-binary.nix {
gmp = pkgs.gmp4;
});
ghc6102Binary = lowPrio (callPackage ../development/compilers/ghc/6.10.2-binary.nix {
gmp = pkgs.gmp4;
});
ghc6121Binary = lowPrio (callPackage ../development/compilers/ghc/6.12.1-binary.nix {
gmp = pkgs.gmp4;
});
ghc704Binary = lowPrio (callPackage ../development/compilers/ghc/7.0.4-binary.nix {
gmp = pkgs.gmp4;
});
ghc742Binary = lowPrio (callPackage ../development/compilers/ghc/7.4.2-binary.nix {
gmp = pkgs.gmp4;
});
ghc782Binary = lowPrio (callPackage ../development/compilers/ghc/7.8.2-binary.nix {
gmp = pkgs.gmp;
});
ghc6101BinaryDarwin = if stdenv.isDarwin then ghc704Binary else ghc6101Binary;
ghc6121BinaryDarwin = if stdenv.isDarwin then ghc704Binary else ghc6121Binary;
# Compiler configurations
#
# Here, we associate compiler versions with bootstrap compiler versions and
# preference functions.
packages_ghc6104 =
packages { ghcPath = ../development/compilers/ghc/6.10.4.nix;
prefFun = ghc6104Prefs;
};
packages_ghc6121 =
packages { ghcPath = ../development/compilers/ghc/6.12.1.nix;
prefFun = ghc6121Prefs;
};
packages_ghc6122 =
packages { ghcPath = ../development/compilers/ghc/6.12.2.nix;
prefFun = ghc6122Prefs;
};
packages_ghc6123 =
packages { ghcPath = ../development/compilers/ghc/6.12.3.nix;
prefFun = ghc6123Prefs;
};
# Will never make it into a platform release, severe bugs; leave at lowPrio.
packages_ghc701 =
packages { ghcPath = ../development/compilers/ghc/7.0.1.nix;
prefFun = ghc701Prefs;
};
packages_ghc702 =
packages { ghcPath = ../development/compilers/ghc/7.0.2.nix;
prefFun = ghc702Prefs;
};
packages_ghc703 =
packages { ghcPath = ../development/compilers/ghc/7.0.3.nix;
prefFun = ghc703Prefs;
};
# The following items are a bit convoluted, but they serve the
# following purpose:
# - for the default version of GHC, both profiling and
# non-profiling versions should be built by Hydra --
# therefore, the _no_profiling and _profiling calls;
# - however, if a user just upgrades a profile, then the
# cabal/libraryProfiling setting should be respected; i.e.,
# the versions not matching the profiling config setting
# should have low priority -- therefore, the use of
# defaultVersionPrioFun;
# - it should be possible to select library versions that
# respect the config setting using the standard
# packages_ghc704 path -- therefore, the additional
# call in packages_ghc704, without recurseIntoAttrs,
# so that Hydra doesn't build these.
packages_ghc704 =
packages { ghcPath = ../development/compilers/ghc/7.0.4.nix;
ghcBinary = ghc6101BinaryDarwin;
prefFun = ghc704Prefs;
};
packages_ghc721 =
packages { ghcPath = ../development/compilers/ghc/7.2.1.nix;
ghcBinary = ghc6121BinaryDarwin;
prefFun = ghc721Prefs;
};
packages_ghc722 =
packages { ghcPath = ../development/compilers/ghc/7.2.2.nix;
ghcBinary = ghc6121BinaryDarwin;
prefFun = ghc722Prefs;
};
packages_ghc741 =
packages { ghcPath = ../development/compilers/ghc/7.4.1.nix;
ghcBinary = ghc6121BinaryDarwin;
prefFun = ghc741Prefs;
};
packages_ghc742 =
packages { ghcPath = ../development/compilers/ghc/7.4.2.nix;
ghcBinary = ghc6121BinaryDarwin;
prefFun = ghc742Prefs;
};
packages_ghc761 =
packages { ghcPath = ../development/compilers/ghc/7.6.1.nix;
ghcBinary = ghc704Binary;
prefFun = ghc763Prefs;
};
packages_ghc762 =
packages { ghcPath = ../development/compilers/ghc/7.6.2.nix;
ghcBinary = ghc704Binary;
prefFun = ghc763Prefs;
};
packages_ghc763 =
packages { ghcPath = ../development/compilers/ghc/7.6.3.nix;
ghcBinary = ghc704Binary;
prefFun = ghc763Prefs;
};
packages_ghc782 =
packages { ghcPath = ../development/compilers/ghc/7.8.2.nix;
ghcBinary = ghc742Binary;
prefFun = ghc782Prefs;
};
# Reasonably current HEAD snapshot. Should *always* be lowPrio.
packages_ghcHEAD =
packages { ghcPath = ../development/compilers/ghc/head.nix;
ghcBinary = ghc782Binary;
prefFun = ghcHEADPrefs;
extraArgs = {
happy = pkgs.haskellPackages.happy_1_19_2;
alex = pkgs.haskellPackages.alex_3_1_3;
};
};
}
-------------- next part --------------
{stdenv, fetchurl, perl, ncurses, gmp, shebangfix}:
stdenv.mkDerivation rec {
version = "7.8.2";
name = "ghc-${version}-binary";
src =
if stdenv.system == "i686-linux" then
fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux-deb7.tar.bz2";
sha256 = "1ippvycx269yyz5qp731g3k3fx4iglh9w5r9bfh1qv6iqizqnwk1";
}
else if stdenv.system == "x86_64-linux" then
fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux-deb7.tar.bz2";
sha256 = "0swmlqpcqfkzvl2j7bnw8vlrshwvlgyxq8r2n8nk8qyvcnmgbz8q";
}
else if stdenv.system == "x86_64-darwin" then
fetchurl {
url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin-mavericks.tar.bz2";
sha256 = "142jmxalm1pi2l951k72lj9i09zpfmmzyhyr5q6wmsqk9yfm22h3";
}
else throw "cannot bootstrap GHC on this platform";
buildInputs = [ perl shebangfix ];
postUnpack =
# Strip is harmful, see also below. It's important that this happens
# first. The GHC Cabal build system makes use of strip by default and
# has hardcoded paths to /usr/bin/strip in many places. We replace
# those below, making them point to our dummy script.
''
mkdir "$TMP/bin"
for i in strip; do
echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
chmod +x "$TMP/bin/$i"
done
PATH="$TMP/bin:$PATH"
'' +
# We have to patch the GMP paths for the integer-gmp package.
''
find . -name integer-gmp.buildinfo \
-exec sed -i "s at extra-lib-dirs: @extra-lib-dirs: ${gmp}/lib@" {} \;
'' +
# There are some /bin/bash shebangs in few files which need to be changed.
''
shebangfix ghc-${version}/inplace/bin/mkdirhier
shebangfix ghc-${version}/utils/ghc-pwd/dist-install/build/tmp/ghc-pwd-bindist
shebangfix ghc-${version}/utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist
'' +
# On Linux, use patchelf to modify the executables so that they can
# find editline/gmp.
(if stdenv.isLinux then ''
find . -type f -perm +100 \
-exec patchelf --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \
--set-rpath "${ncurses}/lib:${gmp}/lib" {} \;
sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
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 = ''
# libgcc_s.so is necessary, so we stick it in our LD_LIBRARY_PATH
export LD_LIBRARY_PATH="${stdenv.gcc.gcc}/lib:$LD_LIBRARY_PATH"
./configure --prefix=$out --with-gmp-libraries=${gmp}/lib --with-gmp-includes=${gmp}/include
'';
# Stripping combined with patchelf breaks the executables (they die
# with a segfault or the kernel even refuses the execve). (NIXPKGS-85)
dontStrip = true;
# No building is necessary, but calling make without flags ironically
# calls install-strip ...
buildPhase = "true";
postInstall =
''
# Sanity check, can ghc create executables?
cd $TMP
mkdir test-ghc; cd test-ghc
cat > main.hs << EOF
module Main where
main = putStrLn "yes"
EOF
$out/bin/ghc --make main.hs
echo compilation ok
[ $(./main) == "yes" ]
'';
meta.license = stdenv.lib.licenses.bsd3;
meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
}
More information about the nix-dev
mailing list