summary refs log tree commit diff
path: root/pkgs/development/haskell-modules/with-packages-wrapper.nix
diff options
context:
space:
mode:
authorCharles Strahan <charles.c.strahan@gmail.com>2015-05-06 15:56:02 -0400
committerCharles Strahan <charles.c.strahan@gmail.com>2015-05-08 11:33:44 -0400
commit929dc4199a57b5d21eb72077f735eb33c4c7b09b (patch)
tree2d5ebe677c30872b8cc9a26a16498ea727789d6c /pkgs/development/haskell-modules/with-packages-wrapper.nix
parent9cb6ebe15ee0a272fe648f8806edbccddbb5c6c1 (diff)
downloadnixpkgs-929dc4199a57b5d21eb72077f735eb33c4c7b09b.tar
nixpkgs-929dc4199a57b5d21eb72077f735eb33c4c7b09b.tar.gz
nixpkgs-929dc4199a57b5d21eb72077f735eb33c4c7b09b.tar.bz2
nixpkgs-929dc4199a57b5d21eb72077f735eb33c4c7b09b.tar.lz
nixpkgs-929dc4199a57b5d21eb72077f735eb33c4c7b09b.tar.xz
nixpkgs-929dc4199a57b5d21eb72077f735eb33c4c7b09b.tar.zst
nixpkgs-929dc4199a57b5d21eb72077f735eb33c4c7b09b.zip
ghcjs: properly wrap binaries in environment
This also:

 1  Builds Setup.hs with ghcjs, which (among other things) defines
    __GHCJS__ and ghcjs_HOST_OS during pre-processing.
 2  Fixes ghc-paths to point at ghcjs and use NIX_GHCJS_* env-vars.
 3  Boots ghcjs into $prefix/lib/$compiler.
Diffstat (limited to 'pkgs/development/haskell-modules/with-packages-wrapper.nix')
-rw-r--r--pkgs/development/haskell-modules/with-packages-wrapper.nix47
1 files changed, 25 insertions, 22 deletions
diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix
index 136566f65f0..4362bacb9ee 100644
--- a/pkgs/development/haskell-modules/with-packages-wrapper.nix
+++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix
@@ -32,6 +32,7 @@ let
   ghc761OrLater = isGhcjs || lib.versionOlder "7.6.1" ghc.version;
   packageDBFlag = if ghc761OrLater then "--global-package-db" else "--global-conf";
   ghcCommand    = if isGhcjs then "ghcjs" else "ghc";
+  ghcCommandCaps= lib.toUpper ghcCommand;
   libDir        = "$out/lib/${ghcCommand}-${ghc.version}";
   docDir        = "$out/share/doc/ghc/html";
   packageCfgDir = "${libDir}/package.conf.d";
@@ -51,10 +52,6 @@ buildEnv {
   postBuild = ''
     . ${makeWrapper}/nix-support/setup-hook
 
-    ${lib.optionalString isGhcjs ''
-    cp -r "${ghc}/${ghc.libDir}/"* ${libDir}/
-    ''}
-
     if test -L "$out/bin"; then
       binTarget="$(readlink -f "$out/bin")"
       rm "$out/bin"
@@ -62,30 +59,36 @@ buildEnv {
       chmod u+w "$out/bin"
     fi
 
-    for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
-      rm -f $out/bin/$prg
-      makeWrapper ${ghc}/bin/$prg $out/bin/$prg             \
-        --add-flags '"-B$NIX_GHC_LIBDIR"'                   \
-        --set "NIX_GHC"        "$out/bin/${ghcCommand}"     \
-        --set "NIX_GHCPKG"     "$out/bin/${ghcCommand}-pkg" \
-        --set "NIX_GHC_DOCDIR" "${docDir}"                  \
-        --set "NIX_GHC_LIBDIR" "${libDir}"                  \
-        ${lib.optionalString withLLVM ''--prefix "PATH" ":" "${llvm}"''}
+    for prg in ${ghcCommand} ${ghcCommand}i ${ghcCommand}-${ghc.version} ${ghcCommand}i-${ghc.version}; do
+      if [[ -x "${ghc}/bin/$prg" ]]; then
+        rm -f $out/bin/$prg
+        makeWrapper ${ghc}/bin/$prg $out/bin/$prg                           \
+          --add-flags '"-B$NIX_${ghcCommandCaps}_LIBDIR"'                   \
+          --set "NIX_${ghcCommandCaps}"        "$out/bin/${ghcCommand}"     \
+          --set "NIX_${ghcCommandCaps}PKG"     "$out/bin/${ghcCommand}-pkg" \
+          --set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}"                  \
+          --set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"                  \
+          ${lib.optionalString withLLVM ''--prefix "PATH" ":" "${llvm}"''}
+      fi
     done
 
     for prg in runghc runhaskell; do
-      rm -f $out/bin/$prg
-      makeWrapper ${ghc}/bin/$prg $out/bin/$prg             \
-        --add-flags "-f $out/bin/ghc"                       \
-        --set "NIX_GHC"        "$out/bin/${ghcCommand}"     \
-        --set "NIX_GHCPKG"     "$out/bin/${ghcCommand}-pkg" \
-        --set "NIX_GHC_DOCDIR" "${docDir}"                  \
-        --set "NIX_GHC_LIBDIR" "${libDir}"
+      if [[ -x "${ghc}/bin/$prg" ]]; then
+        rm -f $out/bin/$prg
+        makeWrapper ${ghc}/bin/$prg $out/bin/$prg                           \
+          --add-flags "-f $out/bin/${ghcCommand}"                           \
+          --set "NIX_${ghcCommandCaps}"        "$out/bin/${ghcCommand}"     \
+          --set "NIX_${ghcCommandCaps}PKG"     "$out/bin/${ghcCommand}-pkg" \
+          --set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}"                  \
+          --set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
+      fi
     done
 
     for prg in ${ghcCommand}-pkg ${ghcCommand}-pkg-${ghc.version}; do
-      rm -f $out/bin/$prg
-      makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
+      if [[ -x "${ghc}/bin/$prg" ]]; then
+        rm -f $out/bin/$prg
+        makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
+      fi
     done
 
     ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}