diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 6c60efe1bce5..f3439e19bdd4 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -150,6 +150,35 @@ assert stdenv.hostPlatform.isWasm -> enableStaticLibraries == false; let + # This is a workaround for the 2024-07-20 staging-next cycle to avoid causing mass rebuilds. + # todo(@reckenrode) Remove this workaround and remove `NIX_COREFOUNDATION_RPATH`, the related hooks, and ld-wrapper support. + nixCoreFoundationRpathWorkaround = stdenv.mkDerivation { + name = "nix-corefoundation-rpath-workaround"; + buildCommand = '' + mkdir -p "$out/nix-support" + cat <<-EOF > "$out/nix-support/setup-hook" + removeUseSystemCoreFoundationFrameworkHook() { + unset NIX_COREFOUNDATION_RPATH + local _hook + for _hook in envBuildBuildHooks envBuildHostHooks envBuildTargetHooks envHostHostHooks envHostTargetHooks envTargetTargetHooks; do + local _index=0 + local _var="\$_hook[@]" + for _var in "\''${!_var}"; do + if [ "\$_var" = "useSystemCoreFoundationFramework" ]; then + unset "\$_hook[\$_index]" + fi + ((++_index)) + done + unset _index + unset _var + done + unset _hook + } + addEnvHooks "\$hostOffset" removeUseSystemCoreFoundationFrameworkHook + EOF + ''; + }; + inherit (lib) optional optionals optionalString versionAtLeast concatStringsSep enableFeature optionalAttrs; @@ -430,7 +459,8 @@ stdenv.mkDerivation ({ inherit depsBuildBuild nativeBuildInputs; buildInputs = otherBuildInputs ++ optionals (!isLibrary) propagatedBuildInputs # For patchShebangsAuto in fixupPhase - ++ optionals stdenv.hostPlatform.isGhcjs [ nodejs ]; + ++ optionals stdenv.hostPlatform.isGhcjs [ nodejs ] + ++ optionals (stdenv.isDarwin && stdenv.isx86_64) [ nixCoreFoundationRpathWorkaround ]; propagatedBuildInputs = optionals isLibrary propagatedBuildInputs; LANG = "en_US.UTF-8"; # GHC needs the locale configured during the Haddock phase.