@@ -19,7 +19,6 @@ in
1919, buildTarget ? ""
2020, buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? []
2121, configureFlags ? []
22−, buildFlags ? []
2322, description ? ""
2423, doCheck ? !isCross && (stdenv.lib.versionOlder "7.4" ghc.version)
2524, doBenchmark ? false
@@ -32,7 +31,7 @@ in
3231, enableSharedExecutables ? false
3332, enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
3433, enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin
35−, enableStaticLibraries ? !hostPlatform.isWindows
34+, enableStaticLibraries ? true
3635, enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4"
3736, extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? []
3837, homepage ? "http://hackage.haskell.org/package/${pname}"
@@ -69,10 +68,6 @@ in
6968
7069assert editedCabalFile != null -> revision != null;
7170
72−# --enable-static does not work on windows. This is a bug in GHC.
73−# --enable-static will pass -staticlib to ghc, which only works for mach-o and elf.
74−assert hostPlatform.isWindows -> enableStaticLibraries == false;
75−
7671let
7772
7873 inherit (stdenv.lib) optional optionals optionalString versionOlder versionAtLeast
@@ -131,8 +126,6 @@ let
131126 crossCabalFlagsString =
132127 stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags);
133128
134− buildFlagsString = optionalString (buildFlags != []) (" " + concatStringsSep " " buildFlags);
135−
136129 defaultConfigureFlags = [
137130 "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid"
138131 (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}")
@@ -176,22 +169,18 @@ let
176169 optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends;
177170
178171 nativeBuildInputs = [ ghc nativeGhc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++
179− setupHaskellDepends ++
180172 buildTools ++ libraryToolDepends ++ executableToolDepends;
181173 propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends;
182− otherBuildInputs = extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++
174+ otherBuildInputs = setupHaskellDepends ++ extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++
183175 optionals (allPkgconfigDepends != []) allPkgconfigDepends ++
184176 optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testToolDepends) ++
185177 optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends ++ benchmarkSystemDepends ++ benchmarkToolDepends);
186−
187178 allBuildInputs = propagatedBuildInputs ++ otherBuildInputs;
188179
189180 haskellBuildInputs = stdenv.lib.filter isHaskellPkg allBuildInputs;
190181 systemBuildInputs = stdenv.lib.filter isSystemPkg allBuildInputs;
191182
192− # When not cross compiling, also include Setup.hs dependencies.
193− ghcEnv = ghc.withPackages (p:
194− haskellBuildInputs ++ stdenv.lib.optional (!isCross) setupHaskellDepends);
183+ ghcEnv = ghc.withPackages (p: haskellBuildInputs);
195184
196185 setupCommand = "./Setup";
197186
@@ -201,22 +190,6 @@ let
201190
202191 nativeGhcCommand = "${nativeGhc.targetPrefix}ghc";
203192
204− buildPkgDb = ghcName: ''
205− if [ -d "$p/lib/${ghcName}/package.conf.d" ]; then
206− cp -f "$p/lib/${ghcName}/package.conf.d/"*.conf $packageConfDir/
207− continue
208− fi
209− if [ -d "$p/include" ]; then
210− configureFlags+=" --extra-include-dirs=$p/include"
211− fi
212− if [ -d "$p/lib" ]; then
213− configureFlags+=" --extra-lib-dirs=$p/lib"
214− fi
215− if [[ -d "$p/Library/Frameworks" ]]; then
216− configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks"
217− fi
218− '';
219−
220193in
221194
222195assert allPkgconfigDepends != [] -> pkgconfig != null;
@@ -257,37 +230,30 @@ stdenv.mkDerivation ({
257230 echo "Build with ${ghc}."
258231 ${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"}
259232
260− '' + (optionalString (setupHaskellDepends != []) ''
261− setupPackageConfDir="$TMPDIR/setup-package.conf.d"
262− mkdir -p $setupPackageConfDir
263− '') + ''
264233 packageConfDir="$TMPDIR/package.conf.d"
265234 mkdir -p $packageConfDir
266235
267236 setupCompileFlags="${concatStringsSep " " setupCompileFlags}"
268237 configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags"
269− ''
270− # We build the Setup.hs on the *build* machine, and as such should only add
271− # dependencies for the build machine.
272− #
273− # pkgs* arrays defined in stdenv/setup.hs
274− + (optionalString (setupHaskellDepends != []) ''
275− for p in "''${pkgsBuildBuild[@]}" "''${pkgsBuildHost[@]}" "''${pkgsBuildTarget[@]}"; do
276− ${buildPkgDb nativeGhc.name}
277− done
278− ${nativeGhcCommand}-pkg --${nativePackageDbFlag}="$setupPackageConfDir" recache
279− '')
280238
281− # For normal components
282− + ''
239+ # host.*Pkgs defined in stdenv/setup.hs
283240 for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do
284− ${buildPkgDb ghc.name}
241+ if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then
242+ cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/
243+ continue
244+ fi
245+ if [ -d "$p/include" ]; then
246+ configureFlags+=" --extra-include-dirs=$p/include"
247+ fi
248+ if [ -d "$p/lib" ]; then
249+ configureFlags+=" --extra-lib-dirs=$p/lib"
250+ fi
285251 done
286252 ''
287253 # only use the links hack if we're actually building dylibs. otherwise, the
288254 # "dynamic-library-dirs" point to nonexistent paths, and the ln command becomes
289255 # "ln -s $out/lib/links", which tries to recreate the links dir and fails
290− + (optionalString (stdenv.isDarwin && (enableSharedLibraries || enableSharedExecutables)) ''
256+ + (optionalString (stdenv.isDarwin && enableSharedLibraries) ''
291257 # Work around a limit in the macOS Sierra linker on the number of paths
292258 # referenced by any one dynamic library:
293259 #
@@ -316,11 +282,7 @@ stdenv.mkDerivation ({
316282 done
317283
318284 echo setupCompileFlags: $setupCompileFlags
319− ${optionalString (setupHaskellDepends != [])
320− ''
321− echo GHC_PACKAGE_PATH="$setupPackageConfDir:"
322− GHC_PACKAGE_PATH="$setupPackageConfDir:" ''
323− }${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
285+ ${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
324286
325287 runHook postCompileBuildDriver
326288 '';
@@ -348,7 +310,7 @@ stdenv.mkDerivation ({
348310
349311 buildPhase = ''
350312 runHook preBuild
351− ${setupCommand} build ${buildTarget}${crossCabalFlagsString}${buildFlagsString}
313+ ${setupCommand} build ${buildTarget}${crossCabalFlagsString}
352314 runHook postBuild
353315 '';
354316