about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
author3noch <eacameron@gmail.com>2017-02-25 17:45:40 -0500
committerCharles Strahan <charles@cstrahan.com>2017-03-02 11:35:11 -0500
commit4b77d425aa5970f39f0637894075d2df8c1575c8 (patch)
tree72d7427bac79601f92d16a1ca04dff262d4e6e47 /pkgs
parent7d356ff69646e78c5f9a362ff8b5912fa9ecec7c (diff)
downloadnixlib-4b77d425aa5970f39f0637894075d2df8c1575c8.tar
nixlib-4b77d425aa5970f39f0637894075d2df8c1575c8.tar.gz
nixlib-4b77d425aa5970f39f0637894075d2df8c1575c8.tar.bz2
nixlib-4b77d425aa5970f39f0637894075d2df8c1575c8.tar.lz
nixlib-4b77d425aa5970f39f0637894075d2df8c1575c8.tar.xz
nixlib-4b77d425aa5970f39f0637894075d2df8c1575c8.tar.zst
nixlib-4b77d425aa5970f39f0637894075d2df8c1575c8.zip
Fix GHCJS HEAD patch; support GHCJS libdir link; use full ghcEnv for GHCJS
Original:
https://github.com/NixOS/nixpkgs-channels/commit/f3110651c81cc3fd4f6d342f0c30d363ea8cd0b0

(With some tweaks from @cstrahan)

closes #23199
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/compilers/ghc/8.0.2.nix7
-rw-r--r--pkgs/development/compilers/ghc/head.nix4
-rw-r--r--pkgs/development/compilers/ghcjs/base.nix10
-rw-r--r--pkgs/development/haskell-modules/generic-builder.nix4
-rw-r--r--pkgs/development/haskell-modules/with-packages-wrapper.nix21
5 files changed, 31 insertions, 15 deletions
diff --git a/pkgs/development/compilers/ghc/8.0.2.nix b/pkgs/development/compilers/ghc/8.0.2.nix
index 5f687aca63a2..605458e71859 100644
--- a/pkgs/development/compilers/ghc/8.0.2.nix
+++ b/pkgs/development/compilers/ghc/8.0.2.nix
@@ -1,9 +1,10 @@
-{ stdenv, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
+{ stdenv, lib, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
 , hscolour, patchutils, sphinx
 
   # 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
 }:
 
 let
@@ -44,7 +45,9 @@ 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"
-  ];
+  ] ++
+    # 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";
 
   # required, because otherwise all symbols from HSffi.o are stripped, and
   # that in turn causes GHCi to abort
diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix
index 3ae7d9c61e45..ed6f4717446d 100644
--- a/pkgs/development/compilers/ghc/head.nix
+++ b/pkgs/development/compilers/ghc/head.nix
@@ -105,7 +105,9 @@ in stdenv.mkDerivation (rec {
     "RANLIB=${stdenv.binutilsCross}/bin/${cross.config}-ranlib"
     "--target=${cross.config}"
     "--enable-bootstrap-with-devel-snapshot"
-  ] ++ (lib.optional ("${cross.config}" == "aarch64-apple-darwin14") "--disable-large-address-space");
+  ] ++
+    # 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";
 
   buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutilsCross ];
 
diff --git a/pkgs/development/compilers/ghcjs/base.nix b/pkgs/development/compilers/ghcjs/base.nix
index 5ffc6e2720e0..ac9419d662ec 100644
--- a/pkgs/development/compilers/ghcjs/base.nix
+++ b/pkgs/development/compilers/ghcjs/base.nix
@@ -1,4 +1,5 @@
 { mkDerivation
+, lib
 , broken ? false
 , test-framework
 , test-framework-hunit
@@ -94,6 +95,11 @@
   ]
 
 , stage2 ? import ./stage2.nix
+
+, patches ? [ ./ghcjs.patch ]
+
+# used for resolving compiler plugins
+, ghcLibdir ? null
 }:
 let
   inherit (bootPkgs) ghc;
@@ -122,7 +128,7 @@ in mkDerivation (rec {
   testDepends = [
     HUnit test-framework test-framework-hunit
   ];
-  patches = [ ./ghcjs.patch ];
+  inherit patches;
   postPatch = ''
     substituteInPlace Setup.hs \
       --replace "/usr/bin/env" "${coreutils}/bin/env"
@@ -165,6 +171,8 @@ in mkDerivation (rec {
         --with-cabal ${cabal-install}/bin/cabal \
         --with-gmp-includes ${gmp.dev}/include \
         --with-gmp-libraries ${gmp.out}/lib
+  '' + lib.optionalString (ghcLibdir != null) ''
+    printf '%s' '${ghcLibdir}' > "$out/lib/ghcjs-${version}/ghc_libdir"
   '';
   passthru = {
     inherit bootPkgs;
diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix
index 42ea03693ecd..e47375e71c73 100644
--- a/pkgs/development/haskell-modules/generic-builder.nix
+++ b/pkgs/development/haskell-modules/generic-builder.nix
@@ -193,11 +193,13 @@ stdenv.mkDerivation ({
     ${jailbreak-cabal}/bin/jailbreak-cabal ${pname}.cabal
   '' + postPatch;
 
+  # for ghcjs, we want to put ghcEnv on PATH so compiler plugins will be available.
+  # TODO(cstrahan): would the same be of benefit to native ghc?
   setupCompilerEnvironmentPhase = ''
     runHook preSetupCompilerEnvironment
 
     echo "Build with ${ghc}."
-    export PATH="${ghc}/bin:$PATH"
+    export PATH="${if ghc.isGhcjs or false then ghcEnv else ghc}/bin:$PATH"
     ${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"}
 
     packageConfDir="$TMPDIR/package.conf.d"
diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix
index c49b81762e71..e04cbe08c2c7 100644
--- a/pkgs/development/haskell-modules/with-packages-wrapper.nix
+++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix
@@ -1,9 +1,12 @@
-{ stdenv, lib, ghc, llvmPackages, packages, buildEnv, makeWrapper
+{ stdenv, lib, ghc, llvmPackages, packages, symlinkJoin, makeWrapper
 , ignoreCollisions ? false, withLLVM ? false
 , postBuild ? ""
 , haskellPackages
+, ghcLibdir ? null # only used by ghcjs, when resolving plugins
 }:
 
+assert ghcLibdir != null -> (ghc.isGhcjs or false);
+
 # This wrapper works only with GHC 6.12 or later.
 assert lib.versionOlder "6.12" ghc.version || ghc.isGhcjs;
 
@@ -48,7 +51,7 @@ let
                    ++ lib.optional stdenv.isDarwin llvmPackages.clang);
 in
 if paths == [] && !withLLVM then ghc else
-buildEnv {
+symlinkJoin {
   # this makes computing paths from the name attribute impossible;
   # if such a feature is needed, the real compiler name should be saved
   # as a dedicated drv attribute, like `compiler-name`
@@ -59,14 +62,6 @@ buildEnv {
   postBuild = ''
     . ${makeWrapper}/nix-support/setup-hook
 
-    # Work around buildEnv sometimes deciding to make bin a symlink
-    if test -L "$out/bin"; then
-      binTarget="$(readlink -f "$out/bin")"
-      rm "$out/bin"
-      cp -r "$binTarget" "$out/bin"
-      chmod u+w "$out/bin"
-    fi
-
     # wrap compiler executables with correct env variables
 
     for prg in ${ghcCommand} ${ghcCommand}i ${ghcCommand}-${ghc.version} ${ghcCommand}i-${ghc.version}; do
@@ -102,6 +97,12 @@ buildEnv {
     done
 
     ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}
+    ${# ghcjs will read the ghc_libdir file when resolving plugins.
+      lib.optionalString (isGhcjs && ghcLibdir != null) ''
+      mkdir -p "${libDir}"
+      rm -f "${libDir}/ghc_libdir"
+      printf '%s' '${ghcLibdir}' > "${libDir}/ghc_libdir"
+    ''}
     $out/bin/${ghcCommand}-pkg check
   '' + postBuild;
   passthru = {