@@ -51,7 +51,7 @@ assert editedCabalFile != null -> revision != null;
5151let
5252
5353 inherit (stdenv.lib) optional optionals optionalString versionOlder
54− concatStringsSep enableFeature optionalAttrs;
54+ concatStringsSep enableFeature optionalAttrs toUpper;
5555
5656 isGhcjs = ghc.isGhcjs or false;
5757
@@ -114,8 +114,9 @@ let
114114
115115 ghcEnv = ghc.withPackages (p: haskellBuildInputs);
116116
117− setupBuilder = if isGhcjs then "${ghc.nativeGhc}/bin/ghc" else "ghc";
117+ setupCommand = if isGhcjs then "${ghc.nodejs}/bin/node ./Setup.jsexe/all.js" else "./Setup";
118118 ghcCommand = if isGhcjs then "ghcjs" else "ghc";
119+ ghcCommandCaps = toUpper ghcCommand;
119120
120121in
121122stdenv.mkDerivation ({
@@ -186,7 +187,7 @@ stdenv.mkDerivation ({
186187 done
187188
188189 echo setupCompileFlags: $setupCompileFlags
189− ${setupBuilder} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
190+ ${ghcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
190191
191192 runHook postCompileBuildDriver
192193 '';
@@ -197,7 +198,7 @@ stdenv.mkDerivation ({
197198 unset GHC_PACKAGE_PATH # Cabal complains if this variable is set during configure.
198199
199200 echo configureFlags: $configureFlags
200− ./Setup configure $configureFlags 2>&1 | ${coreutils}/bin/tee "$NIX_BUILD_TOP/cabal-configure.log"
201+ ${setupCommand} configure $configureFlags 2>&1 | ${coreutils}/bin/tee "$NIX_BUILD_TOP/cabal-configure.log"
201202 if ${gnugrep}/bin/egrep -q '^Warning:.*depends on multiple versions' "$NIX_BUILD_TOP/cabal-configure.log"; then
202203 echo >&2 "*** abort because of serious configure-time warning from Cabal"
203204 exit 1
@@ -210,20 +211,20 @@ stdenv.mkDerivation ({
210211
211212 buildPhase = ''
212213 runHook preBuild
213− ./Setup build ${buildTarget}
214+ ${setupCommand} build ${buildTarget}
214215 runHook postBuild
215216 '';
216217
217218 checkPhase = ''
218219 runHook preCheck
219− ./Setup test ${testTarget}
220+ ${setupCommand} test ${testTarget}
220221 runHook postCheck
221222 '';
222223
223224 haddockPhase = ''
224225 runHook preHaddock
225226 ${optionalString (doHaddock && hasActiveLibrary) ''
226− ./Setup haddock --html \
227+ ${setupCommand} haddock --html \
227228 ${optionalString doHoogle "--hoogle"} \
228229 ${optionalString (hasActiveLibrary && hyperlinkSource) "--hyperlink-source"}
229230 ''}
@@ -233,12 +234,12 @@ stdenv.mkDerivation ({
233234 installPhase = ''
234235 runHook preInstall
235236
236− ${if !hasActiveLibrary then "./Setup install" else ''
237− ./Setup copy
237+ ${if !hasActiveLibrary then "${setupCommand} install" else ''
238+ ${setupCommand} copy
238239 local packageConfDir="$out/lib/${ghc.name}/package.conf.d"
239240 local packageConfFile="$packageConfDir/${pname}-${version}.conf"
240241 mkdir -p "$packageConfDir"
241− ./Setup register --gen-pkg-config=$packageConfFile
242+ ${setupCommand} register --gen-pkg-config=$packageConfFile
242243 local pkgId=$( ${gnused}/bin/sed -n -e 's|^id: ||p' $packageConfFile )
243244 mv $packageConfFile $packageConfDir/$pkgId.conf
244245 ''}
@@ -264,10 +265,10 @@ stdenv.mkDerivation ({
264265 LANG = "en_US.UTF-8";
265266 LOCALE_ARCHIVE = optionalString stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
266267 shellHook = ''
267− export NIX_GHC="${ghcEnv}/bin/${ghcCommand}"
268− export NIX_GHCPKG="${ghcEnv}/bin/${ghcCommand}-pkg"
269− export NIX_GHC_DOCDIR="${ghcEnv}/share/doc/ghc/html"
270− export NIX_GHC_LIBDIR="${ghcEnv}/lib/${ghcEnv.name}"
268+ export NIX_${ghcCommandCaps}="${ghcEnv}/bin/${ghcCommand}"
269+ export NIX_${ghcCommandCaps}PKG="${ghcEnv}/bin/${ghcCommand}-pkg"
270+ export NIX_${ghcCommandCaps}_DOCDIR="${ghcEnv}/share/doc/ghc/html"
271+ export NIX_${ghcCommandCaps}_LIBDIR="${ghcEnv}/lib/${ghcEnv.name}"
271272 '';
272273 };
273274