@@ -1544,10 +1544,36 @@ let
1544
1544
1545
1545
pkgsWithHaskellLibsReadyForStaticLinking = pkgsWithArchiveFiles . extend haskellLibsReadyForStaticLinkingOverlay ;
1546
1546
1547
+ fixGhc = ghcPackage0 : lib . pipe ghcPackage0 [
1548
+ # musl does not support libdw's alleged need for `dlopen()`, see:
1549
+ # https://github.com/nh2/static-haskell-nix/pull/116#issuecomment-1585786484
1550
+ #
1551
+ # Nixpkgs has the `enableDwarf` argument only for GHCs versions that are built
1552
+ # with Hadrian (`common-hadrian.nix`), which in nixpkgs is the case for GHC >= 9.6.
1553
+ # So set `enableDwarf = true`, but not for older versions known to not use Hadrian.
1554
+ ( ghcPackage :
1555
+ if lib . any ( prefix : lib . strings . hasPrefix prefix compiler ) [ "ghc8" "ghc90" "ghc92" "ghc94" ]
1556
+ then ghcPackage # GHC < 9.6, no Hadrian
1557
+ else ghcPackage . override { enableDwarf = false ; }
1558
+ )
1559
+ ] ;
1547
1560
1548
1561
# Overlay all Haskell executables are statically linked.
1549
1562
staticHaskellBinariesOverlay = final : previous : {
1550
1563
haskellPackages = previous . haskellPackages . override ( old : {
1564
+
1565
+ # To override GHC, we need to override both `ghc` and the one in
1566
+ # `buildHaskellPackages` because otherwise this code in `geneic-builder.nix`
1567
+ # will make our package depend on 2 different GHCs:
1568
+ # nativeGhc = buildHaskellPackages.ghc;
1569
+ # depsBuildBuild = [ nativeGhc ] ...
1570
+ # nativeBuildInputs = [ ghc removeReferencesTo ] ...
1571
+ #
1572
+ ghc = fixGhc old . ghc ;
1573
+ buildHaskellPackages = old . buildHaskellPackages . override ( oldBuildHaskellPackages : {
1574
+ ghc = fixGhc oldBuildHaskellPackages . ghc ;
1575
+ } ) ;
1576
+
1551
1577
overrides = final . lib . composeExtensions ( old . overrides or ( _ : _ : { } ) ) ( self : super :
1552
1578
let
1553
1579
# We have to use `useFixedCabal` here, and cannot just rely on the
0 commit comments