diff --git a/pkgs/build-support/cc-wrapper/ld-wrapper.sh b/pkgs/build-support/cc-wrapper/ld-wrapper.sh index a775b6da823..38712665e43 100644 --- a/pkgs/build-support/cc-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/ld-wrapper.sh @@ -145,6 +145,10 @@ if [ "$NIX_@infixSalt@_DONT_SET_RPATH" != 1 ]; then fi done done + + if [ -n "${NIX_COREFOUNDATION_RPATH:-}" ]; then + extraAfter+=(-rpath $NIX_COREFOUNDATION_RPATH) + fi fi diff --git a/pkgs/os-specific/darwin/apple-sdk/default.nix b/pkgs/os-specific/darwin/apple-sdk/default.nix index 73126ce1f5c..957b610f3a2 100644 --- a/pkgs/os-specific/darwin/apple-sdk/default.nix +++ b/pkgs/os-specific/darwin/apple-sdk/default.nix @@ -134,7 +134,7 @@ let propagatedBuildInputs = deps; # don't use pure CF for dylibs that depend on frameworks - setupHook = ../../../build-support/setup-hooks/fix-darwin-frameworks.sh; + setupHook = ./framework-setup-hook.sh; # allows building the symlink tree __impureHostDeps = [ "/System/Library/Frameworks/${name}.framework" ]; diff --git a/pkgs/build-support/setup-hooks/fix-darwin-frameworks.sh b/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh similarity index 77% rename from pkgs/build-support/setup-hooks/fix-darwin-frameworks.sh rename to pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh index cf8416c0838..04d8e878f4f 100644 --- a/pkgs/build-support/setup-hooks/fix-darwin-frameworks.sh +++ b/pkgs/os-specific/darwin/apple-sdk/framework-setup-hook.sh @@ -29,3 +29,14 @@ fixDarwinFrameworksIn() { local dir="$1" fixDarwinFrameworks $(find "$dir" -name "*.dylib") } + + +# This configures the stdenv to use /System/Library/Frameworks/CoreFoundation.framework +# instead of the nix version by including the system frameworks path +# as an rpath entry when creating binaries. + +useSystemCoreFoundationFramework () { + export NIX_COREFOUNDATION_RPATH=/System/Library/Frameworks +} + +envHooks+=(useSystemCoreFoundationFramework) diff --git a/pkgs/os-specific/darwin/apple-source-releases/CF/default.nix b/pkgs/os-specific/darwin/apple-source-releases/CF/default.nix index e44966aa84d..5589d1592f4 100644 --- a/pkgs/os-specific/darwin/apple-source-releases/CF/default.nix +++ b/pkgs/os-specific/darwin/apple-source-releases/CF/default.nix @@ -18,7 +18,7 @@ appleDerivation { --replace "/usr/sbin/" "" \ --replace "/bin/" "" \ --replace "INSTALLNAME=/System" "INSTALLNAME=$out" \ - --replace "install_name_tool -id /System" "install_name_tool -id $out" \ + --replace "install_name_tool -id /System/Library/Frameworks" "install_name_tool -id @rpath" \ --replace 'chown -RH -f root:wheel $(DSTBASE)/CoreFoundation.framework' "" \ --replace 'chmod -RH' 'chmod -R' diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 61b7df19543..6739ce3f5c8 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -300,6 +300,7 @@ in rec { targetPlatform = localSystem; preHook = commonPreHook + '' + export NIX_COREFOUNDATION_RPATH=${pkgs.darwin.CF}/Library/Frameworks export PATH_LOCALE=${pkgs.darwin.locale}/share/locale ''; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bb3b8b419ea..a13b896db19 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -328,8 +328,6 @@ with pkgs; fixDarwinDylibNames = makeSetupHook { } ../build-support/setup-hooks/fix-darwin-dylib-names.sh; - fixDarwinFrameworks = makeSetupHook { } ../build-support/setup-hooks/fix-darwin-frameworks.sh; - keepBuildTree = makeSetupHook { } ../build-support/setup-hooks/keep-build-tree.sh; enableGCOVInstrumentation = makeSetupHook { } ../build-support/setup-hooks/enable-coverage-instrumentation.sh;