Skip to content

Commit 743c156

Browse files
jonathanlkingnh2
authored andcommitted
Reorder pkgsWithArchiveFiles and pkgsWithGhc
1 parent 79945d6 commit 743c156

File tree

1 file changed

+50
-52
lines changed

1 file changed

+50
-52
lines changed

survey/default.nix

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -576,56 +576,6 @@ let
576576
makeFlags = [ "curl_LDFLAGS=-all-static" ];
577577
});
578578

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-
629579
# Overlay that enables `.a` files for as many system packages as possible.
630580
# This is in *addition* to `.so` files.
631581
# See also https://github.com/NixOS/nixpkgs/issues/61575
@@ -918,9 +868,57 @@ let
918868

919869
};
920870

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: {
921906

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+
};
923920

921+
pkgsWithGhc = pkgsWithArchiveFiles.extend setupGhcOverlay;
924922

925923
# This overlay "fixes up" Haskell libraries so that static linking works.
926924
# See note "Don't add new packages here" below!
@@ -1600,7 +1598,7 @@ let
16001598
};
16011599

16021600

1603-
pkgsWithHaskellLibsReadyForStaticLinking = pkgsWithArchiveFiles.extend haskellLibsReadyForStaticLinkingOverlay;
1601+
pkgsWithHaskellLibsReadyForStaticLinking = pkgsWithGhc.extend haskellLibsReadyForStaticLinkingOverlay;
16041602

16051603
# Overlay all Haskell executables are statically linked.
16061604
staticHaskellBinariesOverlay = final: previous: {

0 commit comments

Comments
 (0)