@@ -196,11 +196,6 @@ let
196 LOCALE_ARCHIVE = "${buildPackages.glibcLocales}/lib/locale/locale-archive";
196 LOCALE_ARCHIVE = "${buildPackages.glibcLocales}/lib/locale/locale-archive";
204 haddock = haddockBuilder {
199 haddock = haddockBuilder {
205 inherit componentId component package flags commonConfigureFlags
200 inherit componentId component package flags commonConfigureFlags
206 commonAttrs revision setupGhcOptions doHaddock
201 commonAttrs revision setupGhcOptions doHaddock
@@ -209,174 +204,173 @@ let
210 componentDrv = drv;
205 componentDrv = drv;
214−stdenv.mkDerivation (commonAttrs // {
208+ drv = stdenv.mkDerivation (commonAttrs // {
215− pname = nameOnly;
209+ pname = nameOnly;
216− inherit (package.identifier) version;
210+ inherit (package.identifier) version;
213+ doCrossCheck = false;
215+ inherit dontPatchELF dontStrip;
218+ inherit (package) identifier;
220+ inherit configFiles executableToolDepends cleanSrc exeName;
221+ env = shellWrappers;
222+ profiled = self (drvArgs // { enableLibraryProfiling = true; });
223+ } // lib.optionalAttrs (haskellLib.isLibrary componentId) ({
225+ inherit (haddock) haddockDir; # This is null if `doHaddock = false`
226+ } // lib.optionalAttrs (haddock ? doc) {
227+ # `doHaddock = false` turns the doc of haddock output off
228+ inherit (haddock) doc;
218− doCheck = false;
232+ meta = {
219− doCrossCheck = false;
233+ homepage = package.homepage;
234+ description = package.synopsis;
237+ license-map = import ../lib/cabal-licenses.nix lib;
238+ in license-map.${package.license} or
239+ (builtins.trace "WARNING: license \"${package.license}\" not found" license-map.LicenseRef-OtherLicense);
240+ platforms = if platforms == null then stdenv.lib.platforms.all else platforms;
221− inherit dontPatchELF dontStrip;
243+ propagatedBuildInputs =
244+ frameworks # Frameworks will be needed at link time
245+ # Not sure why pkgconfig needs to be propagatedBuildInputs but
246+ # for gi-gtk-hs it seems to help.
247+ ++ builtins.concatLists pkgconfig;
249+ buildInputs = component.libs
250+ ++ map (d: d.components.library or d) component.depends;
253+ [shellWrappers buildPackages.removeReferencesTo]
254+ ++ executableToolDepends;
257+ ++ (lib.optional enableSeparateDataOutput "data")
258+ ++ (lib.optional keepSource "source");
261+ (lib.optionalString keepSource ''
266+ runHook preConfigure
267+ echo Configure flags:
268+ printf "%q " ${finalConfigureFlags}
270+ $SETUP_HS configure ${finalConfigureFlags}
271+ runHook postConfigure
276+ # https://gitlab.haskell.org/ghc/ghc/issues/9221
277+ $SETUP_HS build ${haskellLib.componentTarget componentId} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " (setupBuildFlags ++ setupGhcOptions)}
281+ checkPhase = "notice: Tests are only executed by building the .run sub-derivation of this component.";
283+ # Note: Cabal does *not* copy test executables during the `install` phase.
285+ # Note 2: if a package contains multiple libs (lib + sublibs) SETUP register will generate a
286+ # folder isntead of a file for the configuration. Therfore if the result is a folder,
287+ # we need to register each and every element of that folder.
289+ # Note 3: if a package has no libs SETUP will not generate anything. This can
290+ # happen when building the `all` component of a package.
292+ target-pkg-and-db = "${ghc.targetPrefix}ghc-pkg -v0 --package-db $out/package.conf.d";
295+ $SETUP_HS copy ${lib.concatStringsSep " " setupInstallFlags}
296+ ${lib.optionalString (haskellLib.isLibrary componentId || haskellLib.isAll componentId) ''
297+ $SETUP_HS register --gen-pkg-config=${name}.conf
298+ ${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
299+ if [ -d "${name}.conf" ]; then
300+ for pkg in ${name}.conf/*; do
301+ ${ghc.targetPrefix}ghc-pkg -v0 --package-db ${configFiles}/${configFiles.packageCfgDir} -f $out/package.conf.d register "$pkg"
303+ elif [ -e "${name}.conf" ]; then
304+ ${ghc.targetPrefix}ghc-pkg -v0 --package-db ${configFiles}/${configFiles.packageCfgDir} -f $out/package.conf.d register ${name}.conf
223− passthru = {
307+ mkdir -p $out/exactDep
224− inherit (package) identifier;
308+ touch $out/exactDep/configure-flags
225− config = component;
309+ touch $out/exactDep/cabal.config
226− inherit configFiles executableToolDepends cleanSrc exeName;
310+
227− env = shellWrappers;
311+ if id=$(${target-pkg-and-db} field ${package.identifier.name} id --simple-output); then
228− profiled = self (drvArgs // { enableLibraryProfiling = true; });
312+ echo "--dependency=${package.identifier.name}=$id" >> $out/exactDep/configure-flags
229− } // lib.optionalAttrs (haskellLib.isLibrary componentId) ({
313+ elif id=$(${target-pkg-and-db} field "z-${package.identifier.name}-z-*" id --simple-output); then
230− inherit haddock;
314+ name=$(${target-pkg-and-db} field "z-${package.identifier.name}-z-*" name --simple-output)
231− inherit (haddock) haddockDir; # This is null if `doHaddock = false`
315+ # so we are dealing with a sublib. As we build sublibs separately, the above
232− } // lib.optionalAttrs (haddock ? doc) {
316+ # query should be safe.
233− # `doHaddock = false` turns the doc of haddock output off
317+ echo "--dependency=''${name#z-${package.identifier.name}-z-}=$id" >> $out/exactDep/configure-flags
234− inherit (haddock) doc;
318+ fi
235− }
319+ if ver=$(${target-pkg-and-db} field ${package.identifier.name} version --simple-output); then
236− );
320+ echo "constraint: ${package.identifier.name} == $ver" >> $out/exactDep/cabal.config
237−
321+ echo "constraint: ${package.identifier.name} installed" >> $out/exactDep/cabal.config
239− homepage = package.homepage;
240− description = package.synopsis;
243− license-map = import ../lib/cabal-licenses.nix lib;
244− in license-map.${package.license} or
245− (builtins.trace "WARNING: license \"${package.license}\" not found" license-map.LicenseRef-OtherLicense);
246− platforms = if platforms == null then stdenv.lib.platforms.all else platforms;
249− propagatedBuildInputs =
324+ touch $out/envDep
250− frameworks # Frameworks will be needed at link time
325+ if id=$(${target-pkg-and-db} field ${package.identifier.name} id --simple-output); then
251− # Not sure why pkgconfig needs to be propagatedBuildInputs but
326+ echo "package-id $id" >> $out/envDep
252− # for gi-gtk-hs it seems to help.
253− ++ builtins.concatLists pkgconfig;
255− buildInputs = component.libs
256− ++ map (d: d.components.library or d) component.depends;
259− [shellWrappers buildPackages.removeReferencesTo]
260− ++ executableToolDepends;
263− ++ (lib.optional enableSeparateDataOutput "data")
264− ++ (lib.optional keepSource "source");
267− (lib.optionalString keepSource ''
272− runHook preConfigure
273− echo Configure flags:
274− printf "%q " ${finalConfigureFlags}
276− $SETUP_HS configure ${finalConfigureFlags}
277− runHook postConfigure
282− # https://gitlab.haskell.org/ghc/ghc/issues/9221
283− $SETUP_HS build ${haskellLib.componentTarget componentId} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " (setupBuildFlags ++ setupGhcOptions)}
287− checkPhase = "notice: Tests are only executed by building the .run sub-derivation of this component.";
289− # Note: Cabal does *not* copy test executables during the `install` phase.
291− # Note 2: if a package contains multiple libs (lib + sublibs) SETUP register will generate a
292− # folder isntead of a file for the configuration. Therfore if the result is a folder,
293− # we need to register each and every element of that folder.
295− # Note 3: if a package has no libs SETUP will not generate anything. This can
296− # happen when building the `all` component of a package.
298− target-pkg-and-db = "${ghc.targetPrefix}ghc-pkg -v0 --package-db $out/package.conf.d";
301− $SETUP_HS copy ${lib.concatStringsSep " " setupInstallFlags}
302− ${lib.optionalString (haskellLib.isLibrary componentId || haskellLib.isAll componentId) ''
303− $SETUP_HS register --gen-pkg-config=${name}.conf
304− ${ghc.targetPrefix}ghc-pkg -v0 init $out/package.conf.d
305− if [ -d "${name}.conf" ]; then
306− for pkg in ${name}.conf/*; do
307− ${ghc.targetPrefix}ghc-pkg -v0 --package-db ${configFiles}/${configFiles.packageCfgDir} -f $out/package.conf.d register "$pkg"
309− elif [ -e "${name}.conf" ]; then
310− ${ghc.targetPrefix}ghc-pkg -v0 --package-db ${configFiles}/${configFiles.packageCfgDir} -f $out/package.conf.d register ${name}.conf
313− mkdir -p $out/exactDep
314− touch $out/exactDep/configure-flags
315− touch $out/exactDep/cabal.config
317− if id=$(${target-pkg-and-db} field ${package.identifier.name} id --simple-output); then
318− echo "--dependency=${package.identifier.name}=$id" >> $out/exactDep/configure-flags
319− elif id=$(${target-pkg-and-db} field "z-${package.identifier.name}-z-*" id --simple-output); then
320− name=$(${target-pkg-and-db} field "z-${package.identifier.name}-z-*" name --simple-output)
321− # so we are dealing with a sublib. As we build sublibs separately, the above
322− # query should be safe.
323− echo "--dependency=''${name#z-${package.identifier.name}-z-}=$id" >> $out/exactDep/configure-flags
325− if ver=$(${target-pkg-and-db} field ${package.identifier.name} version --simple-output); then
326− echo "constraint: ${package.identifier.name} == $ver" >> $out/exactDep/cabal.config
327− echo "constraint: ${package.identifier.name} installed" >> $out/exactDep/cabal.config
331− if id=$(${target-pkg-and-db} field ${package.identifier.name} id --simple-output); then
332− echo "package-id $id" >> $out/envDep
335− ${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || haskellLib.isAll componentId) ''
337− if [ -f ${testExecutable} ]; then
338− mkdir -p $(dirname $out/bin/${exeName})
339− ${if stdenv.hostPlatform.isGhcjs then ''
340− cat <(echo \#!${lib.getBin buildPackages.nodejs}/bin/node) ${testExecutable} >| $out/bin/${exeName}
341− chmod +x $out/bin/${exeName}
343− cp -r ${testExecutable} $(dirname $out/bin/${exeName})
347− # In case `setup copy` did not creat this
348− + (lib.optionalString enableSeparateDataOutput "mkdir -p $data")
349− + (lib.optionalString (stdenv.hostPlatform.isWindows && (haskellLib.mayHaveExecutable componentId)) ''
350− echo "Symlink libffi and gmp .dlls ..."
351− for p in ${lib.concatStringsSep " " [ libffi gmp ]}; do
352− find "$p" -iname '*.dll' -exec ln -s {} $out/bin \;
354− # symlink all .dlls into the local directory.
355− # we ask ghc-pkg for *all* dynamic-library-dirs and then iterate over the unique set
356− # to symlink over dlls as needed.
357− echo "Symlink library dependencies..."
358− for libdir in $(x86_64-pc-mingw32-ghc-pkg --package-db=$packageConfDir field "*" dynamic-library-dirs --simple-output|xargs|sed 's/ /\n/g'|sort -u); do
359− if [ -d "$libdir" ]; then
360− find "$libdir" -iname '*.dll' -exec ln -s {} $out/bin \;
329+ ${(lib.optionalString (haskellLib.isTest componentId || haskellLib.isBenchmark componentId || haskellLib.isAll componentId) ''
331+ if [ -f ${testExecutable} ]; then
332+ mkdir -p $(dirname $out/bin/${exeName})
333+ ${if stdenv.hostPlatform.isGhcjs then ''
334+ cat <(echo \#!${lib.getBin buildPackages.nodejs}/bin/node) ${testExecutable} >| $out/bin/${exeName}
335+ chmod +x $out/bin/${exeName}
337+ cp -r ${testExecutable} $(dirname $out/bin/${exeName})
341+ # In case `setup copy` did not creat this
342+ + (lib.optionalString enableSeparateDataOutput "mkdir -p $data")
343+ + (lib.optionalString (stdenv.hostPlatform.isWindows && (haskellLib.mayHaveExecutable componentId)) ''
344+ echo "Symlink libffi and gmp .dlls ..."
345+ for p in ${lib.concatStringsSep " " [ libffi gmp ]}; do
346+ find "$p" -iname '*.dll' -exec ln -s {} $out/bin \;
363− '')
348+ # symlink all .dlls into the local directory.
364− }
349+ # we ask ghc-pkg for *all* dynamic-library-dirs and then iterate over the unique set
350+ # to symlink over dlls as needed.
351+ echo "Symlink library dependencies..."
352+ for libdir in $(x86_64-pc-mingw32-ghc-pkg --package-db=$packageConfDir field "*" dynamic-library-dirs --simple-output|xargs|sed 's/ /\n/g'|sort -u); do
353+ if [ -d "$libdir" ]; then
354+ find "$libdir" -iname '*.dll' -exec ln -s {} $out/bin \;
365− runHook postInstall
359+ runHook postInstall
366− '' + (lib.optionalString keepSource ''
360+ '' + (lib.optionalString keepSource ''
367− rm -rf dist
361+ rm -rf dist
370− shellHook = ''
364+ shellHook = ''
371− export PATH="${shellWrappers}/bin:$PATH"
365+ export PATH="${shellWrappers}/bin:$PATH"
372− ${shellHookApplied}
366+ ${shellHookApplied}
375−// haskellLib.optionalHooks {
369+ // haskellLib.optionalHooks {
376− # These are the hooks that are not needed by haddock (see commonAttrs for the ones that
370+ # These are the hooks that are not needed by haddock (see commonAttrs for the ones that
377− # are shared with the haddock derivation)
371+ # are shared with the haddock derivation)
379− preBuild postBuild
373+ preBuild postBuild
380− preInstall postInstall;
374+ preInstall postInstall;
382−)); in self)
376+in drv; in self)