From caa1c9699601fb63ccbccdb88aac6e2a1a6223f8 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Tue, 28 May 2024 16:31:39 -0700 Subject: [PATCH] cabal-install: Fix for justStaticExecutables Fixes `cabal-install` to remove references to GHC, mostly through other libraries that are included in the binary. See: #304352 Co-authored-by: sternenseemann --- .../haskell-modules/configuration-common.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 552e5309cdb6e..cefce06d8431d 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -56,7 +56,21 @@ self: super: { }; in { - cabal-install = super.cabal-install.overrideScope cabalInstallOverlay; + cabal-install = + let + cabal-install = super.cabal-install.overrideScope cabalInstallOverlay; + scope = cabal-install.scope; + in + # Some dead code is not properly eliminated on aarch64-darwin, leading + # to bogus references to some dependencies. + overrideCabal (old: lib.optionalAttrs (pkgs.stdenv.hostPlatform.isDarwin && pkgs.stdenv.hostPlatform.isAarch64) { + postInstall = '' + ${old.postInstall or ""} + remove-references-to -t ${scope.HTTP} "$out/bin/.cabal-wrapped" + remove-references-to -t ${scope.Cabal} "$out/bin/.cabal-wrapped" + ''; + }) cabal-install; + cabal-install-solver = super.cabal-install-solver.overrideScope cabalInstallOverlay; # Needs cabal-install >= 3.8 /as well as/ matching Cabal