From feb89eed00eb848da8c9eb56f5dad9fa1e79d536 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 8 Jul 2023 18:57:24 -0600 Subject: [PATCH 1/2] darwin.stdenv: fix portable libsystem hook with sandboxing When sandboxing is enabled, the hook tries to run `install_name_tool` and fails because the system one is inaccessible. Having it use `targetPrefix` allows it to find and use the cross-install_name_tool. --- pkgs/stdenv/adapters.nix | 1 + pkgs/stdenv/darwin/portable-libsystem.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 3e66de48b4df..22da13f5d1eb 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -105,6 +105,7 @@ rec { name = "darwin-portable-libSystem-hook"; substitutions = { libsystem = "${stdenv.cc.libc}/lib/libSystem.B.dylib"; + targetPrefix = stdenv.cc.bintools.targetPrefix; }; } ./darwin/portable-libsystem.sh) ]; diff --git a/pkgs/stdenv/darwin/portable-libsystem.sh b/pkgs/stdenv/darwin/portable-libsystem.sh index f50ccc8d32ee..1fb80c0e5ce9 100644 --- a/pkgs/stdenv/darwin/portable-libsystem.sh +++ b/pkgs/stdenv/darwin/portable-libsystem.sh @@ -7,6 +7,6 @@ fixupOutputHooks+=('fixLibsystemRefs $prefix') fixLibsystemRefs() { if [ -d "$1/bin" ]; then find "$1/bin" -exec \ - install_name_tool -change @libsystem@ /usr/lib/libSystem.B.dylib {} \; + @targetPrefix@install_name_tool -change @libsystem@ /usr/lib/libSystem.B.dylib {} \; fi } From 6f6687ee24a26ef33b47aec23d804e998ca00964 Mon Sep 17 00:00:00 2001 From: Randy Eckenrode Date: Sat, 8 Jul 2023 19:30:33 -0600 Subject: [PATCH 2/2] darwin.stdenv: only run `install_name_tool` on files --- pkgs/stdenv/darwin/portable-libsystem.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/darwin/portable-libsystem.sh b/pkgs/stdenv/darwin/portable-libsystem.sh index 1fb80c0e5ce9..7608c0a0de26 100644 --- a/pkgs/stdenv/darwin/portable-libsystem.sh +++ b/pkgs/stdenv/darwin/portable-libsystem.sh @@ -6,7 +6,7 @@ fixupOutputHooks+=('fixLibsystemRefs $prefix') fixLibsystemRefs() { if [ -d "$1/bin" ]; then - find "$1/bin" -exec \ + find "$1/bin" -type f -exec \ @targetPrefix@install_name_tool -change @libsystem@ /usr/lib/libSystem.B.dylib {} \; fi }