···128129 # Prevents needing to add security_tool as a build tool to all of x509-system's
130 # dependencies.
131- x509-system = if pkgs.stdenv.isDarwin && !pkgs.stdenv.cc.nativeLibc
132 then let inherit (pkgs.darwin) security_tool;
133 in pkgs.lib.overrideDerivation (addBuildDepend super.x509-system security_tool) (drv: {
134 postPatch = (drv.postPatch or "") + ''
···128129 # Prevents needing to add security_tool as a build tool to all of x509-system's
130 # dependencies.
131+ x509-system = if pkgs.stdenv.targetPlatform.isDarwin && !pkgs.stdenv.cc.nativeLibc
132 then let inherit (pkgs.darwin) security_tool;
133 in pkgs.lib.overrideDerivation (addBuildDepend super.x509-system security_tool) (drv: {
134 postPatch = (drv.postPatch or "") + ''
···19, buildTarget ? ""
20, buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? []
21, configureFlags ? []
022, description ? ""
23, doCheck ? !isCross && stdenv.lib.versionOlder "7.4" ghc.version
24, doBenchmark ? false
···31, enableSharedExecutables ? false
32, enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
33, enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin
34-, enableStaticLibraries ? true
35, enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4"
36, extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? []
37, homepage ? "http://hackage.haskell.org/package/${pname}"
···67} @ args:
6869assert editedCabalFile != null -> revision != null;
00007071let
72···125126 crossCabalFlagsString =
127 stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags);
00128129 defaultConfigureFlags = [
130 "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid"
···169 optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends;
170171 nativeBuildInputs = [ ghc nativeGhc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++
0172 buildTools ++ libraryToolDepends ++ executableToolDepends;
173 propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends;
174- otherBuildInputs = setupHaskellDepends ++ extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++
175 allPkgconfigDepends ++
176 optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testToolDepends) ++
177 optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends ++ benchmarkSystemDepends ++ benchmarkToolDepends);
0178 allBuildInputs = propagatedBuildInputs ++ otherBuildInputs;
179180 haskellBuildInputs = stdenv.lib.filter isHaskellPkg allBuildInputs;
181 systemBuildInputs = stdenv.lib.filter isSystemPkg allBuildInputs;
182183- ghcEnv = ghc.withPackages (p: haskellBuildInputs);
00184185 setupCommand = "./Setup";
186···190191 nativeGhcCommand = "${nativeGhc.targetPrefix}ghc";
1920000000000000000193in
194195assert allPkgconfigDepends != [] -> pkgconfig != null;
···230 echo "Build with ${ghc}."
231 ${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"}
2320000233 packageConfDir="$TMPDIR/package.conf.d"
234 mkdir -p $packageConfDir
235236 setupCompileFlags="${concatStringsSep " " setupCompileFlags}"
237 configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags"
00000000000238239- # host.*Pkgs defined in stdenv/setup.hs
0240 for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do
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
251 done
252 ''
253 # only use the links hack if we're actually building dylibs. otherwise, the
254 # "dynamic-library-dirs" point to nonexistent paths, and the ln command becomes
255 # "ln -s $out/lib/links", which tries to recreate the links dir and fails
256- + (optionalString (stdenv.isDarwin && enableSharedLibraries) ''
257 # Work around a limit in the macOS Sierra linker on the number of paths
258 # referenced by any one dynamic library:
259 #
···282 done
283284 echo setupCompileFlags: $setupCompileFlags
285- ${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
0000286287 runHook postCompileBuildDriver
288 '';
···310311 buildPhase = ''
312 runHook preBuild
313- ${setupCommand} build ${buildTarget}${crossCabalFlagsString}
314 runHook postBuild
315 '';
316
···19, buildTarget ? ""
20, buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? []
21, configureFlags ? []
22+, buildFlags ? []
23, description ? ""
24, doCheck ? !isCross && stdenv.lib.versionOlder "7.4" ghc.version
25, doBenchmark ? false
···32, enableSharedExecutables ? false
33, enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
34, enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin
35+, enableStaticLibraries ? !hostPlatform.isWindows
36, enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4"
37, extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? []
38, homepage ? "http://hackage.haskell.org/package/${pname}"
···68} @ args:
6970assert editedCabalFile != null -> revision != null;
71+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;
7576let
77···130131 crossCabalFlagsString =
132 stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags);
133+134+ buildFlagsString = optionalString (buildFlags != []) (" " + concatStringsSep " " buildFlags);
135136 defaultConfigureFlags = [
137 "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid"
···176 optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends;
177178 nativeBuildInputs = [ ghc nativeGhc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++
179+ setupHaskellDepends ++
180 buildTools ++ libraryToolDepends ++ executableToolDepends;
181 propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends;
182+ otherBuildInputs = extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++
183 allPkgconfigDepends ++
184 optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testToolDepends) ++
185 optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends ++ benchmarkSystemDepends ++ benchmarkToolDepends);
186+187 allBuildInputs = propagatedBuildInputs ++ otherBuildInputs;
188189 haskellBuildInputs = stdenv.lib.filter isHaskellPkg allBuildInputs;
190 systemBuildInputs = stdenv.lib.filter isSystemPkg allBuildInputs;
191192+ # When not cross compiling, also include Setup.hs dependencies.
193+ ghcEnv = ghc.withPackages (p:
194+ haskellBuildInputs ++ stdenv.lib.optional (!isCross) setupHaskellDepends);
195196 setupCommand = "./Setup";
197···201202 nativeGhcCommand = "${nativeGhc.targetPrefix}ghc";
203204+ 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+220in
221222assert allPkgconfigDepends != [] -> pkgconfig != null;
···257 echo "Build with ${ghc}."
258 ${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"}
259260+ '' + (optionalString (setupHaskellDepends != []) ''
261+ setupPackageConfDir="$TMPDIR/setup-package.conf.d"
262+ mkdir -p $setupPackageConfDir
263+ '') + ''
264 packageConfDir="$TMPDIR/package.conf.d"
265 mkdir -p $packageConfDir
266267 setupCompileFlags="${concatStringsSep " " setupCompileFlags}"
268 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+ '')
280281+ # For normal components
282+ + ''
283 for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do
284+ ${buildPkgDb ghc.name}
000000000285 done
286 ''
287 # only use the links hack if we're actually building dylibs. otherwise, the
288 # "dynamic-library-dirs" point to nonexistent paths, and the ln command becomes
289 # "ln -s $out/lib/links", which tries to recreate the links dir and fails
290+ + (optionalString (stdenv.isDarwin && (enableSharedLibraries || enableSharedExecutables)) ''
291 # Work around a limit in the macOS Sierra linker on the number of paths
292 # referenced by any one dynamic library:
293 #
···316 done
317318 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
324325 runHook postCompileBuildDriver
326 '';
···348349 buildPhase = ''
350 runHook preBuild
351+ ${setupCommand} build ${buildTarget}${crossCabalFlagsString}${buildFlagsString}
352 runHook postBuild
353 '';
354
+2
pkgs/development/haskell-modules/lib.nix
···131 */
132 appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; });
13300134 /* removeConfigureFlag drv x is a Haskell package like drv, but with
135 all cabal configure arguments that are equal to x removed.
136
···131 */
132 appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; });
133134+ appendBuildFlag = drv: x: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ [x]; });
135+ appendBuildFlags = drv: xs: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ xs; });
136 /* removeConfigureFlag drv x is a Haskell package like drv, but with
137 all cabal configure arguments that are equal to x removed.
138