about summary refs log tree commit diff
path: root/pkgs/development/haskell-modules/with-packages-wrapper.nix
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/development/haskell-modules/with-packages-wrapper.nix
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/development/haskell-modules/with-packages-wrapper.nix')
-rw-r--r--pkgs/development/haskell-modules/with-packages-wrapper.nix21
1 files changed, 11 insertions, 10 deletions
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 = {