lol
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 18.03-beta 162 lines 6.3 kB view raw
1{ stdenv 2, fetchurl, perl, gcc, llvm_39 3, ncurses5, gmp, libiconv 4}: 5 6# Prebuilt only does native 7assert stdenv.targetPlatform == stdenv.hostPlatform; 8 9let 10 libPath = stdenv.lib.makeLibraryPath ([ 11 ncurses5 gmp 12 ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv); 13 14 libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY" 15 + "LD_LIBRARY_PATH"; 16 17in 18 19stdenv.mkDerivation rec { 20 version = "8.2.1"; 21 22 name = "ghc-${version}-binary"; 23 24 src = fetchurl ({ 25 "i686-linux" = { 26 url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-deb8-linux.tar.xz"; 27 sha256 = "d86f9c157dd4161a8acb14062c131c8985a4f65fc856603c373502be1d50c95e"; 28 }; 29 "x86_64-linux" = { 30 url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-deb8-linux.tar.xz"; 31 sha256 = "543b81bf610240bd0398111d6c6607a9094dc2d159b564057d46c8a3d1aaa130"; 32 }; 33 "armv7l-linux" = { 34 url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-armv7-deb8-linux.tar.xz"; 35 sha256 = "0f0e5e1d4fad3fa1a87ca1fe0d19242f4a94d158b7b8a08f99efefd98b51b019"; 36 }; 37 "aarch64-linux" = { 38 url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-aarch64-deb8-linux.tar.xz"; 39 sha256 = "61dab9c95ef9f9af8bce7338863fda3e42945eb46194b12d922b6d0dc245d0c2"; 40 }; 41 "x86_64-darwin" = { 42 url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; 43 sha256 = "900c802025fb630060dbd30f9738e5d107a4ca5a50d5c1262cd3e69fe4467188"; 44 }; 45 }.${stdenv.hostPlatform.system} 46 or (throw "cannot bootstrap GHC on this platform")); 47 48 nativeBuildInputs = [ perl ]; 49 buildInputs = stdenv.lib.optionals (stdenv.targetPlatform.isArm || stdenv.targetPlatform.isAarch64) [ llvm_39 ]; 50 51 # Cannot patchelf beforehand due to relative RPATHs that anticipate 52 # the final install location/ 53 ${libEnvVar} = libPath; 54 55 postUnpack = 56 # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib 57 # during linking 58 stdenv.lib.optionalString stdenv.isDarwin '' 59 export NIX_LDFLAGS+=" -no_dtrace_dof" 60 # not enough room in the object files for the full path to libiconv :( 61 for exe in $(find . -type f -executable); do 62 isScript $exe && continue 63 ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib 64 install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe 65 done 66 '' + 67 68 # Some scripts used during the build need to have their shebangs patched 69 '' 70 patchShebangs ghc-${version}/utils/ 71 '' + 72 73 # Strip is harmful, see also below. It's important that this happens 74 # first. The GHC Cabal build system makes use of strip by default and 75 # has hardcoded paths to /usr/bin/strip in many places. We replace 76 # those below, making them point to our dummy script. 77 '' 78 mkdir "$TMP/bin" 79 for i in strip; do 80 echo '#! ${stdenv.shell}' > "$TMP/bin/$i" 81 chmod +x "$TMP/bin/$i" 82 done 83 PATH="$TMP/bin:$PATH" 84 '' + 85 # We have to patch the GMP paths for the integer-gmp package. 86 '' 87 find . -name integer-gmp.buildinfo \ 88 -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \; 89 '' + stdenv.lib.optionalString stdenv.isDarwin '' 90 find . -name base.buildinfo \ 91 -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \; 92 '' + 93 # Rename needed libraries and binaries, fix interpreter 94 stdenv.lib.optionalString stdenv.isLinux '' 95 find . -type f -perm -0100 -exec patchelf \ 96 --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \ 97 --replace-needed libtinfo.so libtinfo.so.5 \ 98 --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" {} \; 99 100 paxmark m ./ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 101 102 sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 103 sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 104 ''; 105 106 configurePlatforms = [ ]; 107 configureFlags = [ 108 "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib" 109 "--with-gmp-includes=${stdenv.lib.getDev gmp}/include" 110 ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"; 111 112 # Stripping combined with patchelf breaks the executables (they die 113 # with a segfault or the kernel even refuses the execve). (NIXPKGS-85) 114 dontStrip = true; 115 116 # No building is necessary, but calling make without flags ironically 117 # calls install-strip ... 118 dontBuild = true; 119 120 # On Linux, use patchelf to modify the executables so that they can 121 # find editline/gmp. 122 preFixup = stdenv.lib.optionalString stdenv.isLinux '' 123 for p in $(find "$out" -type f -executable); do 124 if isELF "$p"; then 125 echo "Patchelfing $p" 126 patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p 127 fi 128 done 129 '' + stdenv.lib.optionalString stdenv.isDarwin '' 130 # not enough room in the object files for the full path to libiconv :( 131 for exe in $(find "$out" -type f -executable); do 132 isScript $exe && continue 133 ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib 134 install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe 135 done 136 137 for file in $(find "$out" -name setup-config); do 138 substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)" 139 done 140 ''; 141 142 doInstallCheck = true; 143 installCheckPhase = '' 144 unset ${libEnvVar} 145 # Sanity check, can ghc create executables? 146 cd $TMP 147 mkdir test-ghc; cd test-ghc 148 cat > main.hs << EOF 149 {-# LANGUAGE TemplateHaskell #-} 150 module Main where 151 main = putStrLn \$([|"yes"|]) 152 EOF 153 $out/bin/ghc --make main.hs || exit 1 154 echo compilation ok 155 [ $(./main) == "yes" ] 156 ''; 157 158 passthru = { targetPrefix = ""; }; 159 160 meta.license = stdenv.lib.licenses.bsd3; 161 meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux" "aarch64-linux"]; 162}