@@ -32,6 +32,7 @@ let
3232 ghc761OrLater = isGhcjs || lib.versionOlder "7.6.1" ghc.version;
3333 packageDBFlag = if ghc761OrLater then "--global-package-db" else "--global-conf";
3434 ghcCommand = if isGhcjs then "ghcjs" else "ghc";
35+ ghcCommandCaps= lib.toUpper ghcCommand;
3536 libDir = "$out/lib/${ghcCommand}-${ghc.version}";
3637 docDir = "$out/share/doc/ghc/html";
3738 packageCfgDir = "${libDir}/package.conf.d";
@@ -51,10 +52,6 @@ buildEnv {
5152 postBuild = ''
5253 . ${makeWrapper}/nix-support/setup-hook
5354
54− ${lib.optionalString isGhcjs ''
55− cp -r "${ghc}/${ghc.libDir}/"* ${libDir}/
56− ''}
57−
5855 if test -L "$out/bin"; then
5956 binTarget="$(readlink -f "$out/bin")"
6057 rm "$out/bin"
@@ -62,30 +59,36 @@ buildEnv {
6259 chmod u+w "$out/bin"
6360 fi
6461
65− for prg in ghc ghci ghc-${ghc.version} ghci-${ghc.version}; do
66− rm -f $out/bin/$prg
67− makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
68− --add-flags '"-B$NIX_GHC_LIBDIR"' \
69− --set "NIX_GHC" "$out/bin/${ghcCommand}" \
70− --set "NIX_GHCPKG" "$out/bin/${ghcCommand}-pkg" \
71− --set "NIX_GHC_DOCDIR" "${docDir}" \
72− --set "NIX_GHC_LIBDIR" "${libDir}" \
73− ${lib.optionalString withLLVM ''--prefix "PATH" ":" "${llvm}"''}
62+ for prg in ${ghcCommand} ${ghcCommand}i ${ghcCommand}-${ghc.version} ${ghcCommand}i-${ghc.version}; do
63+ if [[ -x "${ghc}/bin/$prg" ]]; then
64+ rm -f $out/bin/$prg
65+ makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
66+ --add-flags '"-B$NIX_${ghcCommandCaps}_LIBDIR"' \
67+ --set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \
68+ --set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \
69+ --set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \
70+ --set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}" \
71+ ${lib.optionalString withLLVM ''--prefix "PATH" ":" "${llvm}"''}
72+ fi
7473 done
7574
7675 for prg in runghc runhaskell; do
77− rm -f $out/bin/$prg
78− makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
79− --add-flags "-f $out/bin/ghc" \
80− --set "NIX_GHC" "$out/bin/${ghcCommand}" \
81− --set "NIX_GHCPKG" "$out/bin/${ghcCommand}-pkg" \
82− --set "NIX_GHC_DOCDIR" "${docDir}" \
83− --set "NIX_GHC_LIBDIR" "${libDir}"
76+ if [[ -x "${ghc}/bin/$prg" ]]; then
77+ rm -f $out/bin/$prg
78+ makeWrapper ${ghc}/bin/$prg $out/bin/$prg \
79+ --add-flags "-f $out/bin/${ghcCommand}" \
80+ --set "NIX_${ghcCommandCaps}" "$out/bin/${ghcCommand}" \
81+ --set "NIX_${ghcCommandCaps}PKG" "$out/bin/${ghcCommand}-pkg" \
82+ --set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \
83+ --set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"
84+ fi
8485 done
8586
8687 for prg in ${ghcCommand}-pkg ${ghcCommand}-pkg-${ghc.version}; do
87− rm -f $out/bin/$prg
88− makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
88+ if [[ -x "${ghc}/bin/$prg" ]]; then
89+ rm -f $out/bin/$prg
90+ makeWrapper ${ghc}/bin/$prg $out/bin/$prg --add-flags "${packageDBFlag}=${packageCfgDir}"
91+ fi
8992 done
9093
9194 ${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}