From 0d3355a439f2100f232e0319a0cb393134dbbdbe Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Fri, 19 May 2023 15:49:09 -0400 Subject: [PATCH 1/2] swift-corelibs: set NIX_COREFOUNDATION_RPATH in a hook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #230870. Thanks to @eliasnaur for the test case and for rasining awareness and to @veprbl for the work done on #111385. This takes a slightly different approach from those two PRs. The hook is set unconditionally. The stdenv bootstrap doesn’t really need CF at all, so setting the hook is harmless. This simplifies things. --- pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix | 4 +++- .../darwin/swift-corelibs/pure-corefoundation-hook.sh | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 pkgs/os-specific/darwin/swift-corelibs/pure-corefoundation-hook.sh diff --git a/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix b/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix index 7c48d695e11d..1e7aeb3689ea 100644 --- a/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix +++ b/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, fetchurl, ninja, python3, curl, libxml2, objc4, ICU }: +{ lib, stdenv, fetchFromGitHub, fetchurl, makeSetupHook, ninja, python3, curl, libxml2, objc4, ICU }: let # 10.12 adds a new sysdir.h that our version of CF in the main derivation depends on, but @@ -104,4 +104,6 @@ stdenv.mkDerivation { ln -s Versions/Current/$i $base/$i done ''; + + darwinEnvHook = makeSetupHook { name = "darwin-env-hook"; } ./pure-corefoundation-hook.sh; } diff --git a/pkgs/os-specific/darwin/swift-corelibs/pure-corefoundation-hook.sh b/pkgs/os-specific/darwin/swift-corelibs/pure-corefoundation-hook.sh new file mode 100644 index 000000000000..d5539f50861a --- /dev/null +++ b/pkgs/os-specific/darwin/swift-corelibs/pure-corefoundation-hook.sh @@ -0,0 +1,7 @@ +usePureCoreFoundation() { +# Avoid overriding value set by the impure CF + if [ -z "${NIX_COREFOUNDATION_RPATH:-}" ]; then + export NIX_COREFOUNDATION_RPATH=@out@/Library/Frameworks + fi +} +addEnvHooks "$hostOffset" usePureCoreFoundation From 7c043234ecd084e90947aaf63cea5be96beee015 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Tue, 30 May 2023 13:28:34 -0400 Subject: [PATCH 2/2] darwin.stdenv: drop NIX_COREFOUNDATION_RPATH from preHook Rely on swift-corefoundation to set this in its hook. That way, it will be dropped from the `extraBuildInputs` during a cross build. --- pkgs/stdenv/darwin/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 780717db56b8..64e33aa772e0 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -683,7 +683,6 @@ rec { targetPlatform = localSystem; preHook = commonPreHook + '' - export NIX_COREFOUNDATION_RPATH=${pkgs.darwin.CF}/Library/Frameworks export PATH_LOCALE=${pkgs.darwin.locale}/share/locale '';