|
576 | 576 | makeFlags = [ "curl_LDFLAGS=-all-static" ]; |
577 | 577 | }); |
578 | 578 |
|
579 | | - fixGhc = ghcPackage0: lib.pipe ghcPackage0 [ |
580 | | - # musl does not support libdw's alleged need for `dlopen()`, see: |
581 | | - # https://github.com/nh2/static-haskell-nix/pull/116#issuecomment-1585786484 |
582 | | - # |
583 | | - # Nixpkgs has the `enableDwarf` argument only for GHCs versions that are built |
584 | | - # with Hadrian (`common-hadrian.nix`), which in nixpkgs is the case for GHC >= 9.6. |
585 | | - # So set `enableDwarf = true`, but not for older versions known to not use Hadrian. |
586 | | - (ghcPackage: |
587 | | - if lib.any (prefix: lib.strings.hasPrefix prefix compiler) ["ghc8" "ghc90" "ghc92" "ghc94"] |
588 | | - then ghcPackage # GHC < 9.6, no Hadrian |
589 | | - else ghcPackage.override { enableDwarf = false; } |
590 | | - ) |
591 | | - (ghcPackage: |
592 | | - ghcPackage.override { |
593 | | - enableRelocatedStaticLibs = useArchiveFilesForTemplateHaskell; |
594 | | - enableShared = !useArchiveFilesForTemplateHaskell; |
595 | | - } |
596 | | - ) |
597 | | - ]; |
598 | | - |
599 | | - setupGhcOverlay = final: previous: |
600 | | - let |
601 | | - initialHaskellPackages = |
602 | | - if integer-simple |
603 | | - # Note we don't have to set the `-finteger-simple` flag for packages that GHC |
604 | | - # depends on (e.g. text), because nix + GHC already do this for us: |
605 | | - # https://github.com/ghc/ghc/blob/ghc-8.4.3-release/ghc.mk#L620-L626 |
606 | | - # https://github.com/peterhoeg/nixpkgs/commit/50050f3cc9e006daa6800f15a29e258c6e6fa4b3#diff-2f6f8fd152c14d37ebd849aa6382257aR35 |
607 | | - then previous.haskell.packages.integer-simple."${compiler}" |
608 | | - else previous.haskell.packages."${compiler}"; |
609 | | - in |
610 | | - { |
611 | | - haskellPackages = initialHaskellPackages.override (old: { |
612 | | - |
613 | | - # To override GHC, we need to override both `ghc` and the one in |
614 | | - # `buildHaskellPackages` because otherwise this code in `geneic-builder.nix` |
615 | | - # will make our package depend on 2 different GHCs: |
616 | | - # nativeGhc = buildHaskellPackages.ghc; |
617 | | - # depsBuildBuild = [ nativeGhc ] ... |
618 | | - # nativeBuildInputs = [ ghc removeReferencesTo ] ... |
619 | | - # |
620 | | - ghc = fixGhc old.ghc; |
621 | | - buildHaskellPackages = old.buildHaskellPackages.override (oldBuildHaskellPackages: { |
622 | | - ghc = fixGhc oldBuildHaskellPackages.ghc; |
623 | | - }); |
624 | | - }); |
625 | | - }; |
626 | | - |
627 | | - pkgsWithGhc = pkgs.extend setupGhcOverlay; |
628 | | - |
629 | 579 | # Overlay that enables `.a` files for as many system packages as possible. |
630 | 580 | # This is in *addition* to `.so` files. |
631 | 581 | # See also https://github.com/NixOS/nixpkgs/issues/61575 |
|
918 | 868 |
|
919 | 869 | }; |
920 | 870 |
|
| 871 | + pkgsWithArchiveFiles = pkgs.extend archiveFilesOverlay; |
| 872 | + |
| 873 | + fixGhc = ghcPackage0: lib.pipe ghcPackage0 [ |
| 874 | + # musl does not support libdw's alleged need for `dlopen()`, see: |
| 875 | + # https://github.com/nh2/static-haskell-nix/pull/116#issuecomment-1585786484 |
| 876 | + # |
| 877 | + # Nixpkgs has the `enableDwarf` argument only for GHCs versions that are built |
| 878 | + # with Hadrian (`common-hadrian.nix`), which in nixpkgs is the case for GHC >= 9.6. |
| 879 | + # So set `enableDwarf = true`, but not for older versions known to not use Hadrian. |
| 880 | + (ghcPackage: |
| 881 | + if lib.any (prefix: lib.strings.hasPrefix prefix compiler) ["ghc8" "ghc90" "ghc92" "ghc94"] |
| 882 | + then ghcPackage # GHC < 9.6, no Hadrian |
| 883 | + else ghcPackage.override { enableDwarf = false; } |
| 884 | + ) |
| 885 | + (ghcPackage: |
| 886 | + ghcPackage.override { |
| 887 | + enableRelocatedStaticLibs = useArchiveFilesForTemplateHaskell; |
| 888 | + enableShared = !useArchiveFilesForTemplateHaskell; |
| 889 | + } |
| 890 | + ) |
| 891 | + ]; |
| 892 | + |
| 893 | + setupGhcOverlay = final: previous: |
| 894 | + let |
| 895 | + initialHaskellPackages = |
| 896 | + if integer-simple |
| 897 | + # Note we don't have to set the `-finteger-simple` flag for packages that GHC |
| 898 | + # depends on (e.g. text), because nix + GHC already do this for us: |
| 899 | + # https://github.com/ghc/ghc/blob/ghc-8.4.3-release/ghc.mk#L620-L626 |
| 900 | + # https://github.com/peterhoeg/nixpkgs/commit/50050f3cc9e006daa6800f15a29e258c6e6fa4b3#diff-2f6f8fd152c14d37ebd849aa6382257aR35 |
| 901 | + then previous.haskell.packages.integer-simple."${compiler}" |
| 902 | + else previous.haskell.packages."${compiler}"; |
| 903 | + in |
| 904 | + { |
| 905 | + haskellPackages = initialHaskellPackages.override (old: { |
921 | 906 |
|
922 | | - pkgsWithArchiveFiles = pkgsWithGhc.extend archiveFilesOverlay; |
| 907 | + # To override GHC, we need to override both `ghc` and the one in |
| 908 | + # `buildHaskellPackages` because otherwise this code in `geneic-builder.nix` |
| 909 | + # will make our package depend on 2 different GHCs: |
| 910 | + # nativeGhc = buildHaskellPackages.ghc; |
| 911 | + # depsBuildBuild = [ nativeGhc ] ... |
| 912 | + # nativeBuildInputs = [ ghc removeReferencesTo ] ... |
| 913 | + # |
| 914 | + ghc = fixGhc old.ghc; |
| 915 | + buildHaskellPackages = old.buildHaskellPackages.override (oldBuildHaskellPackages: { |
| 916 | + ghc = fixGhc oldBuildHaskellPackages.ghc; |
| 917 | + }); |
| 918 | + }); |
| 919 | + }; |
923 | 920 |
|
| 921 | + pkgsWithGhc = pkgsWithArchiveFiles.extend setupGhcOverlay; |
924 | 922 |
|
925 | 923 | # This overlay "fixes up" Haskell libraries so that static linking works. |
926 | 924 | # See note "Don't add new packages here" below! |
@@ -1600,7 +1598,7 @@ let |
1600 | 1598 | }; |
1601 | 1599 |
|
1602 | 1600 |
|
1603 | | - pkgsWithHaskellLibsReadyForStaticLinking = pkgsWithArchiveFiles.extend haskellLibsReadyForStaticLinkingOverlay; |
| 1601 | + pkgsWithHaskellLibsReadyForStaticLinking = pkgsWithGhc.extend haskellLibsReadyForStaticLinkingOverlay; |
1604 | 1602 |
|
1605 | 1603 | # Overlay all Haskell executables are statically linked. |
1606 | 1604 | staticHaskellBinariesOverlay = final: previous: { |
|
0 commit comments