Skip to content

Instantly share code, notes, and snippets.

@dhess
Created May 15, 2017 23:31
Show Gist options
  • Save dhess/9b3c20783519adba4b7e3098137ea81e to your computer and use it in GitHub Desktop.
Save dhess/9b3c20783519adba4b7e3098137ea81e to your computer and use it in GitHub Desktop.
{stdenv, fetchurl, dpkg, perl, ncurses5, gmp, libiconv, makeWrapper}:
stdenv.mkDerivation rec {
version = "8.0.2";
name = "ghc-${version}-binary";
src =
if stdenv.system == "x86_64-linux" then
fetchurl {
url = "mirror://debian/pool/main/g/ghc/ghc_8.0.1-17+b1_amd64.deb";
sha256 = "f7afab2b127b82637f741a8d8cd4cec4e688d8a85c05b5d732a2373b6dca7cbd";
}
else throw "cannot bootstrap GHC on this platform";
buildInputs = [ dpkg perl ];
nativeBuildInputs = [ makeWrapper ];
dontConfigure = true;
# 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 ...
dontBuild = true;
unpackPhase = "dpkg-deb -x $src .";
installPhase = ''
substituteInPlace usr/lib/ghc/bin/ghc-split --replace /usr/bin/perl ${perl}/bin/perl
substituteInPlace usr/lib/ghc/settings --replace /usr/bin/perl ${perl}/bin/perl
for prog in ghc-8.0.1 ghci-8.0.1 ghc-pkg-8.0.1 haddock-ghc-8.0.1 hpc hsc2hs runghc-8.0.1; do
substituteInPlace usr/bin/$prog --replace /usr $out
done
mv usr/bin .
rm usr/lib/ghc/package.conf.d
mv usr/lib .
mv var/lib/ghc/package.conf.d ./lib/ghc/package.conf.d
mv usr/share .
rmdir usr
rmdir var/lib/ghc
rmdir var/lib
rmdir var
cp -r . $out
ln -sv "${ncurses5.out}/lib/libncurses.so" "$out/lib/libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5"
find . -type f -perm -0100 \
-exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${stdenv.lib.makeLibraryPath [ "$out" gmp ]}" {} \;
'';
meta.license = stdenv.lib.licenses.bsd3;
meta.platforms = ["x86_64-linux" ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment