Skip to content

Commit 0a4a3b6

Browse files
committed
WIP: More cleanup for Cabal patching
1 parent 075a41e commit 0a4a3b6

File tree

1 file changed

+63
-18
lines changed

1 file changed

+63
-18
lines changed

survey/default.nix

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ in
3333
# When changing this, also change the default version of Cabal declared below
3434
compiler ? "ghc843",
3535

36+
defaultCabalPackageVersionComingWithGhc ? "Cabal_2_2_0_1",
37+
3638
normalHaskellPackages ?
3739
if integer-simple
3840
# Note we don't have to set the `-finteger-simple` flag for packages that GHC
@@ -242,7 +244,7 @@ let
242244
extraPrefix = "";
243245
};
244246

245-
applyPatchesToCabalDrv = cabalDrv: builtins.trace "cabalDrv: ${builtins.toJSON cabalDrv}" pkgs.haskell.lib.overrideCabal cabalDrv (old: {
247+
applyPatchesToCabalDrv = cabalDrv: pkgs.haskell.lib.overrideCabal cabalDrv (old: {
246248
patches =
247249
# Patches we know are merged in a certain cabal version
248250
# (we include them conditionally here anyway, for the case
@@ -306,7 +308,7 @@ let
306308
let
307309
patchIfCabal = drv:
308310
if (drv.pname or "") == "Cabal" # the `ghc` package has not `pname` attribute, so we default to "" here
309-
then builtins.trace "calling cabalDrv: ${builtins.toJSON drv}" applyPatchesToCabalDrv drv
311+
then applyPatchesToCabalDrv drv
310312
else drv;
311313
patchCabalInPackageList = drvs:
312314
let
@@ -434,9 +436,16 @@ let
434436
in {
435437

436438
Cabal =
437-
if builtins.isNull super.Cabal # if null, Cabal is a non-overriden package coming with GHC
438-
then builtins.trace "calling cabalDrv2: ${builtins.toJSON pkgs.haskell.packages."${compiler}".Cabal_2_2_0_1} ${toString (builtins.attrNames pkgs.haskell.packages."${compiler}".Cabal_2_2_0_1)}" applyPatchesToCabalDrv pkgs.haskell.packages."${compiler}".Cabal_2_2_0_1
439-
else builtins.trace "calling cabalDrv: ${builtins.toJSON super.Cabal}" applyPatchesToCabalDrv super.Cabal;
439+
# If null, super.Cabal is a non-overriden package coming with GHC.
440+
# In that case, we can't patch it (we can't add patches to derivations that are null).
441+
# So we need to instead add a not-with-GHC Cabal package and patch that.
442+
# The best choice for that is the version that comes with the GHC.
443+
# Unfortunately we can't query that easily, so we maintain that manually
444+
# in `defaultCabalPackageVersionComingWithGhc`.
445+
# That effort will go away once all our Cabal patches are upstreamed.
446+
if builtins.isNull super.Cabal
447+
then applyPatchesToCabalDrv pkgs.haskell.packages."${compiler}"."${defaultCabalPackageVersionComingWithGhc}"
448+
else applyPatchesToCabalDrv super.Cabal;
440449

441450
# Helpers for other packages
442451

@@ -451,19 +460,6 @@ let
451460
# It's not clear if it's safe to disable this as key functionality may be broken
452461
hslua = dontCheck super.hslua;
453462

454-
hsyslog = useFixedCabal super.hsyslog;
455-
456-
# Without this, when compiling `hsyslog`, GHC sees 2 Cabal
457-
# libraries, the unfixed one provided by cabal-doctest
458-
# (which is GHC's global unfixed one), and the fixed one as declared
459-
# for `hsyslog` through statify.
460-
# GHC does NOT issue a warning in that case, but just silently
461-
# picks the one from the global package database (the one
462-
# cabal-doctest would want), instead of the one from our
463-
# `useFixedCabal` one which is given on the command line at
464-
# https://github.com/NixOS/nixpkgs/blob/e7e5aaa0b9/pkgs/development/haskell-modules/generic-builder.nix#L330
465-
cabal-doctest = useFixedCabal super.cabal-doctest;
466-
467463
darcs =
468464
addStaticLinkerFlagsWithPkgconfig
469465
(super.darcs.override { curl = curl_static; })
@@ -640,6 +636,13 @@ let
640636

641637
});
642638

639+
# We have to use `useFixedCabal` here, and cannot just rely on the
640+
# "Cabal = ..." we override up in `haskellPackagesWithLibsReadyForStaticLinking`,
641+
# because that `Cabal` isn't used in all packages:
642+
# If a package doesn't explicitly depend on the `Cabal` package, then
643+
# for compiling its `Setup.hs` the Cabal package that comes with GHC
644+
# (that is in the default GHC package DB) is used instead, which
645+
# obviously doesn' thave our patches.
643646
statify = drv: with pkgs.haskell.lib; pkgs.lib.foldl appendConfigureFlag (disableLibraryProfiling (disableSharedExecutables (useFixedCabal drv))) [
644647
# "--ghc-option=-fPIC"
645648
"--enable-executable-static" # requires `useFixedCabal`
@@ -703,6 +706,48 @@ in
703706
allStackageExecutables =
704707
lib.filterAttrs (name: x: isStackageExecutable name) haskellPackages;
705708

709+
workingStackageExecutables =
710+
builtins.removeAttrs allStackageExecutables [
711+
# List of executables that don't work for reasons not yet investigated.
712+
# When changing this file, we should always check if this list grows or shrinks.
713+
"Agda"
714+
"Allure"
715+
"ALUT"
716+
"clash-ghc"
717+
"credential-store"
718+
"csg"
719+
"debug"
720+
"diagrams-builder"
721+
"dotenv"
722+
"ersatz"
723+
"filter-logger"
724+
"gtk3"
725+
"hamilton"
726+
"haskell-gi"
727+
"hquantlib"
728+
"ihaskell"
729+
"ipython-kernel"
730+
"jack"
731+
"LambdaHack"
732+
"language-puppet"
733+
"learn-physics"
734+
"lens-regex"
735+
"leveldb-haskell"
736+
"microformats2-parser"
737+
"mmark-cli"
738+
"odbc"
739+
"OpenAL"
740+
"rasterific-svg"
741+
"sdl2"
742+
"sdl2-gfx"
743+
"sdl2-image"
744+
"sdl2-mixer"
745+
"sdl2-ttf"
746+
"soxlib"
747+
"yesod-paginator"
748+
"yoga"
749+
"zeromq4-patterns"
750+
];
706751

707752
inherit normalPkgs;
708753
inherit pkgs;

0 commit comments

Comments
 (0)