From 207fb75488d1321d96ff13ab919d37f5ec63e15a Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Mon, 30 Oct 2023 14:32:22 +0100 Subject: [PATCH] bazel_7: darwin (sandbox) fixes --- .../tools/build-managers/bazel/bazel_7/tests.nix | 12 ++++++------ .../tools/build-managers/bazel/cpp-test.nix | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pkgs/development/tools/build-managers/bazel/bazel_7/tests.nix b/pkgs/development/tools/build-managers/bazel/bazel_7/tests.nix index 64f08352f541..ef8ec035e5a5 100644 --- a/pkgs/development/tools/build-managers/bazel/bazel_7/tests.nix +++ b/pkgs/development/tools/build-managers/bazel/bazel_7/tests.nix @@ -75,15 +75,15 @@ let } '' # Bazel needs a real home for self-extraction and internal cache - export HOME=$(mktemp -d) + mkdir bazel_home + export HOME=$PWD/bazel_home ${# Concurrent bazel invocations have the same workspace path. - # On darwin, for some reason, it means they access and corrupt the same execroot. - # Having a different workspace path ensures we use different execroots. - # A different user seems to be enough for a different bazel cache root. + # On darwin, for some reason, it means they access and corrupt the + # same outputRoot, outputUserRoot and outputBase + # Ensure they use build-local outputRoot by setting TEST_TMPDIR lib.optionalString isDarwin '' - export USER=$(basename $HOME) - # cd $(mktemp --tmpdir=. -d) + export TEST_TMPDIR=$HOME/.cache/bazel '' } ${# Speed-up tests by caching bazel extraction. diff --git a/pkgs/development/tools/build-managers/bazel/cpp-test.nix b/pkgs/development/tools/build-managers/bazel/cpp-test.nix index 22be00312be1..8129c3235f36 100644 --- a/pkgs/development/tools/build-managers/bazel/cpp-test.nix +++ b/pkgs/development/tools/build-managers/bazel/cpp-test.nix @@ -53,6 +53,7 @@ let '' + lib.optionalString (stdenv.isDarwin) '' --cxxopt=-x --cxxopt=c++ --host_cxxopt=-x --host_cxxopt=c++ \ --linkopt=-stdlib=libc++ --host_linkopt=-stdlib=libc++ \ + '' + lib.optionalString (stdenv.isDarwin && Foundation != null) '' --linkopt=-Wl,-F${Foundation}/Library/Frameworks \ --linkopt=-L${darwin.libobjc}/lib \ '';