diff --git a/pkgs/os-specific/darwin/swift-corelibs/corefoundation-setup-hook.sh b/pkgs/os-specific/darwin/swift-corelibs/corefoundation-setup-hook.sh new file mode 100644 index 0000000000000..6eba947c01697 --- /dev/null +++ b/pkgs/os-specific/darwin/swift-corelibs/corefoundation-setup-hook.sh @@ -0,0 +1,8 @@ +useCoreFoundationFramework () { + # Avoid overriding value set by the impure CF + if [ -z "${NIX_COREFOUNDATION_RPATH+x}" ]; then + export NIX_COREFOUNDATION_RPATH=@out@/Library/Frameworks + fi +} + +addEnvHooks "$hostOffset" useCoreFoundationFramework diff --git a/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix b/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix index 9f0ee4db118cd..2d8fd3b6bc194 100644 --- a/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix +++ b/pkgs/os-specific/darwin/swift-corelibs/corefoundation.nix @@ -1,4 +1,5 @@ -{ lib, stdenv, fetchFromGitHub, fetchurl, ninja, python3, curl, libxml2, objc4, ICU }: +{ lib, stdenv, fetchFromGitHub, fetchurl, ninja, python3, curl, libxml2, objc4, ICU +, withRpathHook ? true }: let # 10.12 adds a new sysdir.h that our version of CF in the main derivation depends on, but @@ -10,7 +11,7 @@ let }; in -stdenv.mkDerivation { +stdenv.mkDerivation ({ name = "swift-corefoundation"; src = fetchFromGitHub { @@ -111,4 +112,6 @@ stdenv.mkDerivation { ln -s Versions/Current/$i $base/$i done ''; -} +} // lib.optionalAttrs withRpathHook { + setupHook = ./corefoundation-setup-hook.sh; +}) diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index 3e5c46709ac76..f4de34ad33420 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -29,6 +29,8 @@ let "/usr/lib/libSystem.B.dylib" "/usr/lib/system/libunc.dylib" # This dependency is "hidden", so our scanning code doesn't pick it up ]; + + withoutRpathHook = drv: drv.override { withRpathHook = false; }; in rec { commonPreHook = '' export NIX_ENFORCE_NO_NATIVE=''${NIX_ENFORCE_NO_NATIVE-1} @@ -343,7 +345,8 @@ in rec { darwin = super.darwin // { inherit (darwin) binutils dyld Libsystem xnu configd ICU libdispatch libclosure - launchd CF darwin-stubs; + launchd darwin-stubs; + CF = withoutRpathHook darwin.CF; }; }; in with prevStage; stageFun 2 prevStage { @@ -352,7 +355,7 @@ in rec { ''; extraNativeBuildInputs = [ pkgs.xz ]; - extraBuildInputs = [ pkgs.darwin.CF ]; + extraBuildInputs = [ (withoutRpathHook pkgs.darwin.CF) ]; libcxx = pkgs.libcxx; allowedRequisites = @@ -399,7 +402,7 @@ in rec { # and instead goes by $PATH, which happens to contain bootstrapTools. So it goes and # patches our shebangs back to point at bootstrapTools. This makes sure bash comes first. extraNativeBuildInputs = with pkgs; [ xz ]; - extraBuildInputs = [ pkgs.darwin.CF pkgs.bash ]; + extraBuildInputs = [ (withoutRpathHook pkgs.darwin.CF) pkgs.bash ]; libcxx = pkgs.libcxx; extraPreHook = '' @@ -448,16 +451,16 @@ in rec { darwin = super.darwin // rec { inherit (darwin) dyld Libsystem libiconv locale darwin-stubs; - CF = super.darwin.CF.override { + CF = withoutRpathHook (super.darwin.CF.override { inherit libxml2; python3 = prevStage.python3; - }; + }); }; }; in with prevStage; stageFun 4 prevStage { shell = "${pkgs.bash}/bin/bash"; extraNativeBuildInputs = with pkgs; [ xz ]; - extraBuildInputs = [ pkgs.darwin.CF pkgs.bash ]; + extraBuildInputs = [ (withoutRpathHook pkgs.darwin.CF) pkgs.bash ]; libcxx = pkgs.libcxx; extraPreHook = '' @@ -503,7 +506,6 @@ in rec { targetPlatform = localSystem; preHook = commonPreHook + '' - export NIX_COREFOUNDATION_RPATH=${pkgs.darwin.CF}/Library/Frameworks export PATH_LOCALE=${pkgs.darwin.locale}/share/locale '';