···122 # instead of `libtinfo.so.*.`
123 { nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; }
124 ];
125+ isHadrian = true;
126 };
127 };
128 };
···421422 # Our Cabal compiler name
423 haskellCompilerName = "ghc-${version}";
424+ } // lib.optionalAttrs (binDistUsed.isHadrian or false) {
425+ # Normal GHC derivations expose the hadrian derivation used to build them
426+ # here. In the case of bindists we just make sure that the attribute exists,
427+ # as it is used for checking if a GHC derivation has been built with hadrian.
428+ # The isHadrian mechanism will become obsolete with GHCs that use hadrian
429+ # exclusively, i.e. 9.6 (and 9.4?).
430+ hadrian = null;
431 };
432433 meta = rec {
···137 # instead of `libtinfo.so.*.`
138 { nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; }
139 ];
140+ isHadrian = true;
141 };
142 };
143 };
···417418 # Our Cabal compiler name
419 haskellCompilerName = "ghc-${version}";
420+ } // lib.optionalAttrs (binDistUsed.isHadrian or false) {
421+ # Normal GHC derivations expose the hadrian derivation used to build them
422+ # here. In the case of bindists we just make sure that the attribute exists,
423+ # as it is used for checking if a GHC derivation has been built with hadrian.
424+ # The isHadrian mechanism will become obsolete with GHCs that use hadrian
425+ # exclusively, i.e. 9.6 (and 9.4?).
426+ hadrian = null;
427 };
428429 meta = rec {
···94 { nixPackage = ncurses6; fileToCheckFor = null; }
95 { nixPackage = libiconv; fileToCheckFor = null; }
96 ];
97+ isHadrian = true;
98 };
99 aarch64-darwin = {
100 variantSuffix = "";
···108 { nixPackage = ncurses6; fileToCheckFor = null; }
109 { nixPackage = libiconv; fileToCheckFor = null; }
110 ];
111+ isHadrian = true;
112 };
113 };
114 # Binary distributions for the musl libc for the respective system.
···120 sha256 = "026348947d30a156b84de5d6afeaa48fdcb2795b47954cd8341db00d3263a481";
121 };
122 isStatic = true;
123+ isHadrian = true;
124 # We can't check the RPATH for statically linked executable
125 exePathForLibraryCheck = null;
126 archSpecificLibraries = [
···403404 # Our Cabal compiler name
405 haskellCompilerName = "ghc-${version}";
406+ } // lib.optionalAttrs (binDistUsed.isHadrian or false) {
407+ # Normal GHC derivations expose the hadrian derivation used to build them
408+ # here. In the case of bindists we just make sure that the attribute exists,
409+ # as it is used for checking if a GHC derivation has been built with hadrian.
410+ # The isHadrian mechanism will become obsolete with GHCs that use hadrian
411+ # exclusively, i.e. 9.6 (and 9.4?).
412+ hadrian = null;
413 };
414415 meta = rec {
···105 singleton-bool = doJailbreak super.singleton-bool;
106 rope-utf16-splay = doDistribute self.rope-utf16-splay_0_4_0_0;
107 shake-cabal = doDistribute self.shake-cabal_0_2_2_3;
108-109 base-orphans = dontCheck super.base-orphans;
110111 # Note: Any compilation fixes need to be done on the versioned attributes,
112 # since those are used for the internal dependencies between the versioned
113 # hspec packages in configuration-common.nix.
114- hspec = self.hspec_2_10_8;
115- hspec-core = self.hspec-core_2_10_8;
116 hspec-meta = self.hspec-meta_2_10_5;
117- hspec-discover = self.hspec-discover_2_10_8;
118119 # the dontHaddock is due to a GHC panic. might be this bug, not sure.
120 # https://gitlab.haskell.org/ghc/ghc/-/issues/21619
···184 })
185 self.ghc-exactprint_1_6_1_1;
186187- # 2022-10-06: plugins disabled for hls 1.8.0.0 based on
188 # https://haskell-language-server.readthedocs.io/en/latest/support/plugin-support.html#current-plugin-support-tiers
189 haskell-language-server = super.haskell-language-server.override {
190- hls-refactor-plugin = null;
191 hls-eval-plugin = null;
192- hls-floskell-plugin = null;
193- hls-ormolu-plugin = null;
194- hls-rename-plugin = null;
195 hls-stylish-haskell-plugin = null;
196 };
197198 # https://github.com/tweag/ormolu/issues/941
199- ormolu = overrideCabal (drv: {
200- libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
201- }) (disableCabalFlag "fixity-th" super.ormolu);
202 fourmolu = overrideCabal (drv: {
203 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
204 }) (disableCabalFlag "fixity-th" super.fourmolu_0_10_1_0);
205206- # The Haskell library has additional dependencies when compiled with ghc-9.4.x.
207- X11-xft = addExtraLibraries [pkgs.xorg.libXau pkgs.xorg.libXdmcp pkgs.expat] super.X11-xft;
00000000000208209}
···105 singleton-bool = doJailbreak super.singleton-bool;
106 rope-utf16-splay = doDistribute self.rope-utf16-splay_0_4_0_0;
107 shake-cabal = doDistribute self.shake-cabal_0_2_2_3;
108+ libmpd = doJailbreak super.libmpd;
109 base-orphans = dontCheck super.base-orphans;
110111 # Note: Any compilation fixes need to be done on the versioned attributes,
112 # since those are used for the internal dependencies between the versioned
113 # hspec packages in configuration-common.nix.
114+ hspec = self.hspec_2_10_9;
115+ hspec-core = self.hspec-core_2_10_9;
116 hspec-meta = self.hspec-meta_2_10_5;
117+ hspec-discover = self.hspec-discover_2_10_9;
118119 # the dontHaddock is due to a GHC panic. might be this bug, not sure.
120 # https://gitlab.haskell.org/ghc/ghc/-/issues/21619
···184 })
185 self.ghc-exactprint_1_6_1_1;
186187+ # 2023-02-01: plugins disabled for hls 1.9.0.0 based on
188 # https://haskell-language-server.readthedocs.io/en/latest/support/plugin-support.html#current-plugin-support-tiers
189 haskell-language-server = super.haskell-language-server.override {
0190 hls-eval-plugin = null;
191+ hls-ormolu-plugin = null; # This plugin is supposed to work, but fails to compile.
192+ hls-floskell-plugin = null; # This plugin is supposed to work, but fails to compile.
193+ hls-rename-plugin = null; # This plugin is supposed to work, but fails to compile.
194 hls-stylish-haskell-plugin = null;
195 };
196197 # https://github.com/tweag/ormolu/issues/941
198+ ormolu = doDistribute self.ormolu_0_5_2_0;
00199 fourmolu = overrideCabal (drv: {
200 libraryHaskellDepends = drv.libraryHaskellDepends ++ [ self.file-embed ];
201 }) (disableCabalFlag "fixity-th" super.fourmolu_0_10_1_0);
202203+ # Apply workaround for Cabal 3.8 bug https://github.com/haskell/cabal/issues/8455
204+ # by making `pkg-config --static` happy. Note: Cabal 3.9 is also affected, so
205+ # the GHC 9.6 configuration may need similar overrides eventually.
206+ X11-xft = __CabalEagerPkgConfigWorkaround super.X11-xft;
207+ # Jailbreaks for https://github.com/gtk2hs/gtk2hs/issues/323#issuecomment-1416723309
208+ glib = __CabalEagerPkgConfigWorkaround (doJailbreak super.glib);
209+ cairo = __CabalEagerPkgConfigWorkaround (doJailbreak super.cairo);
210+ pango = __CabalEagerPkgConfigWorkaround (doJailbreak super.pango);
211+212+ # The gtk2hs setup hook provided by this package lacks the ppOrdering field that
213+ # recent versions of Cabal require. This leads to builds like cairo and glib
214+ # failing during the Setup.hs phase: https://github.com/gtk2hs/gtk2hs/issues/323.
215+ gtk2hs-buildtools = appendPatch ./patches/gtk2hs-buildtools-fix-ghc-9.4.x.patch super.gtk2hs-buildtools;
216217}
···199 defaultConfigureFlags = [
200 "--verbose"
201 "--prefix=$out"
202- "--libdir=\\$prefix/lib/\\$compiler"
0203 "--libsubdir=\\$abi/\\$libname"
204 (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghcNameWithPrefix}")
205 (optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}")
···207 "--with-gcc=$CC" # Clang won't work without that extra information.
208 ] ++ [
209 "--package-db=$packageConfDir"
210- (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghcNameWithPrefix}/${pname}-${version}")
211 (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
212 (optionalString enableParallelBuilding "--ghc-options=${parallelBuildingFlags}")
213 (optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp")
···284 ghcCommand = "${ghc.targetPrefix}${ghcCommand'}";
285286 ghcNameWithPrefix = "${ghc.targetPrefix}${ghc.haskellCompilerName}";
000287288 nativeGhcCommand = "${nativeGhc.targetPrefix}ghc";
289290- buildPkgDb = ghcName: packageConfDir: ''
291 # If this dependency has a package database, then copy the contents of it,
292 # unless it is one of our GHCs. These can appear in our dependencies when
293 # we are doing native builds, and they have package databases in them, but
···297 # we compile with it, and doing so can result in having multiple copies of
298 # e.g. Cabal in the database with the same name and version, which is
299 # ambiguous.
300- if [ -d "$p/lib/${ghcName}/package.conf.d" ] && [ "$p" != "${ghc}" ] && [ "$p" != "${nativeGhc}" ]; then
301- cp -f "$p/lib/${ghcName}/package.conf.d/"*.conf ${packageConfDir}/
302 continue
303 fi
304 '';
···363 # pkgs* arrays defined in stdenv/setup.hs
364 + ''
365 for p in "''${pkgsBuildBuild[@]}" "''${pkgsBuildHost[@]}" "''${pkgsBuildTarget[@]}"; do
366- ${buildPkgDb "${nativeGhcCommand}-${nativeGhc.version}" "$setupPackageConfDir"}
367 done
368 ${nativeGhcCommand}-pkg --${nativePackageDbFlag}="$setupPackageConfDir" recache
369 ''
370 # For normal components
371 + ''
372 for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do
373- ${buildPkgDb ghcNameWithPrefix "$packageConfDir"}
374 if [ -d "$p/include" ]; then
375 configureFlags+=" --extra-include-dirs=$p/include"
376 fi
···510 # just the target specified; "install" will error here, since not all targets have been built.
511 else ''
512 ${setupCommand} copy ${buildTarget}
513- local packageConfDir="$out/lib/${ghcNameWithPrefix}/package.conf.d"
514 local packageConfFile="$packageConfDir/${pname}-${version}.conf"
515 mkdir -p "$packageConfDir"
516 ${setupCommand} register --gen-pkg-config=$packageConfFile
···539 ${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"}
540 ${optionalString (enableSharedExecutables && isExecutable && !isGhcjs && stdenv.isDarwin && lib.versionOlder ghc.version "7.10") ''
541 for exe in "${binDir}/"* ; do
542- install_name_tool -add_rpath "$out/lib/ghc-${ghc.version}/${pname}-${version}" "$exe"
543 done
544 ''}
545···675 "NIX_${ghcCommandCaps}_DOCDIR" = "${ghcEnv}/share/doc/ghc/html";
676 "NIX_${ghcCommandCaps}_LIBDIR" = if ghc.isHaLVM or false
677 then "${ghcEnv}/lib/HaLVM-${ghc.version}"
678- else "${ghcEnv}/lib/${ghcCommand}-${ghc.version}";
679 });
680681 env = envFunc { };
···199 defaultConfigureFlags = [
200 "--verbose"
201 "--prefix=$out"
202+ # Note: This must be kept in sync manually with mkGhcLibdir
203+ ("--libdir=\\$prefix/lib/\\$compiler" + lib.optionalString (ghc ? hadrian) "/lib")
204 "--libsubdir=\\$abi/\\$libname"
205 (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghcNameWithPrefix}")
206 (optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}")
···208 "--with-gcc=$CC" # Clang won't work without that extra information.
209 ] ++ [
210 "--package-db=$packageConfDir"
211+ (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/${ghcLibdir}/${pname}-${version}")
212 (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names")
213 (optionalString enableParallelBuilding "--ghc-options=${parallelBuildingFlags}")
214 (optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp")
···285 ghcCommand = "${ghc.targetPrefix}${ghcCommand'}";
286287 ghcNameWithPrefix = "${ghc.targetPrefix}${ghc.haskellCompilerName}";
288+ mkGhcLibdir = ghc: "lib/${ghc.targetPrefix}${ghc.haskellCompilerName}"
289+ + lib.optionalString (ghc ? hadrian) "/lib";
290+ ghcLibdir = mkGhcLibdir ghc;
291292 nativeGhcCommand = "${nativeGhc.targetPrefix}ghc";
293294+ buildPkgDb = thisGhc: packageConfDir: ''
295 # If this dependency has a package database, then copy the contents of it,
296 # unless it is one of our GHCs. These can appear in our dependencies when
297 # we are doing native builds, and they have package databases in them, but
···301 # we compile with it, and doing so can result in having multiple copies of
302 # e.g. Cabal in the database with the same name and version, which is
303 # ambiguous.
304+ if [ -d "$p/${mkGhcLibdir thisGhc}/package.conf.d" ] && [ "$p" != "${ghc}" ] && [ "$p" != "${nativeGhc}" ]; then
305+ cp -f "$p/${mkGhcLibdir thisGhc}/package.conf.d/"*.conf ${packageConfDir}/
306 continue
307 fi
308 '';
···367 # pkgs* arrays defined in stdenv/setup.hs
368 + ''
369 for p in "''${pkgsBuildBuild[@]}" "''${pkgsBuildHost[@]}" "''${pkgsBuildTarget[@]}"; do
370+ ${buildPkgDb nativeGhc "$setupPackageConfDir"}
371 done
372 ${nativeGhcCommand}-pkg --${nativePackageDbFlag}="$setupPackageConfDir" recache
373 ''
374 # For normal components
375 + ''
376 for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do
377+ ${buildPkgDb ghc "$packageConfDir"}
378 if [ -d "$p/include" ]; then
379 configureFlags+=" --extra-include-dirs=$p/include"
380 fi
···514 # just the target specified; "install" will error here, since not all targets have been built.
515 else ''
516 ${setupCommand} copy ${buildTarget}
517+ local packageConfDir="$out/${ghcLibdir}/package.conf.d"
518 local packageConfFile="$packageConfDir/${pname}-${version}.conf"
519 mkdir -p "$packageConfDir"
520 ${setupCommand} register --gen-pkg-config=$packageConfFile
···543 ${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"}
544 ${optionalString (enableSharedExecutables && isExecutable && !isGhcjs && stdenv.isDarwin && lib.versionOlder ghc.version "7.10") ''
545 for exe in "${binDir}/"* ; do
546+ install_name_tool -add_rpath "$out/${ghcLibdir}/${pname}-${version}" "$exe"
547 done
548 ''}
549···679 "NIX_${ghcCommandCaps}_DOCDIR" = "${ghcEnv}/share/doc/ghc/html";
680 "NIX_${ghcCommandCaps}_LIBDIR" = if ghc.isHaLVM or false
681 then "${ghcEnv}/lib/HaLVM-${ghc.version}"
682+ else "${ghcEnv}/${ghcLibdir}";
683 });
684685 env = envFunc { };
···464 allowInconsistentDependencies = overrideCabal (drv: {
465 allowInconsistentDependencies = true;
466 });
467+468+ # Work around a Cabal bug requiring pkg-config --static --libs to work even
469+ # when linking dynamically, affecting Cabal 3.8 and 3.9.
470+ # https://github.com/haskell/cabal/issues/8455
471+ #
472+ # For this, we treat the runtime system/pkg-config dependencies of a Haskell
473+ # derivation as if they were propagated from their dependencies which allows
474+ # pkg-config --static to work in most cases.
475+ #
476+ # Warning: This function may change or be removed at any time, e.g. if we find
477+ # a different workaround, upstream fixes the bug or we patch Cabal.
478+ __CabalEagerPkgConfigWorkaround =
479+ let
480+ # Take list of derivations and return list of the transitive dependency
481+ # closure, only taking into account buildInputs. Loosely based on
482+ # closePropagationFast.
483+ propagatedPlainBuildInputs = drvs:
484+ builtins.map (i: i.val) (
485+ builtins.genericClosure {
486+ startSet = builtins.map (drv:
487+ { key = drv.outPath; val = drv; }
488+ ) drvs;
489+ operator = { val, ... }:
490+ if !lib.isDerivation val
491+ then [ ]
492+ else
493+ builtins.concatMap (drv:
494+ if !lib.isDerivation drv
495+ then [ ]
496+ else [ { key = drv.outPath; val = drv; } ]
497+ ) (val.buildInputs or [ ] ++ val.propagatedBuildInputs or [ ]);
498+ }
499+ );
500+ in
501+ overrideCabal (old: {
502+ benchmarkPkgconfigDepends = propagatedPlainBuildInputs old.benchmarkPkgconfigDepends or [ ];
503+ executablePkgconfigDepends = propagatedPlainBuildInputs old.executablePkgconfigDepends or [ ];
504+ libraryPkgconfigDepends = propagatedPlainBuildInputs old.libraryPkgconfigDepends or [ ];
505+ testPkgconfigDepends = propagatedPlainBuildInputs old.testPkgconfigDepends or [ ];
506+ });
507}