From a909f97e59e8ac410e99b9e890dcd5a51810ed72 Mon Sep 17 00:00:00 2001 From: Samuel Ainsworth Date: Sat, 21 Feb 2026 01:04:47 -0500 Subject: [PATCH 1/2] bazel_7: fix enableNixHacks build on darwin The enableNixHacks patch unconditionally treated any existing repository directory as valid, bypassing marker file validation. When bazel's module extension framework created empty directories for extension-generated repos (like local_config_xcode), the hack returned these before the repository rule could populate them with BUILD files. Fix by checking for BUILD/BUILD.bazel file existence before considering a cached repo valid. Empty repos now fall through to execute the repository rule, which generates proper stubs. Fixes: https://github.com/NixOS/nixpkgs/issues/390395 --- .../bazel_7/nix-build-bazel-package-hacks.patch | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/ba/bazel_7/nix-build-bazel-package-hacks.patch b/pkgs/by-name/ba/bazel_7/nix-build-bazel-package-hacks.patch index 28fe172f3e5c..82e6715b203d 100644 --- a/pkgs/by-name/ba/bazel_7/nix-build-bazel-package-hacks.patch +++ b/pkgs/by-name/ba/bazel_7/nix-build-bazel-package-hacks.patch @@ -10,9 +10,9 @@ index 53e6494656..22261cd268 100644 import java.util.Map; import java.util.Optional; import java.util.TreeMap; -@@ -193,16 +194,11 @@ public final class RepositoryDelegatorFunction implements SkyFunction { +@@ -193,16 +194,15 @@ public final class RepositoryDelegatorFunction implements SkyFunction { } - + if (shouldUseCachedRepos(env, handler, repoRoot, rule)) { - // Make sure marker file is up-to-date; correctly describes the current repository state - byte[] markerHash = digestWriter.areRepositoryAndMarkerFileConsistent(handler, env); @@ -20,8 +20,12 @@ index 53e6494656..22261cd268 100644 - return null; - } - if (markerHash != null) { // repo exist & up-to-date -+ { -+ // Nix hack: Always consider cached dirs as up-to-date ++ // Nix hack: Skip marker file validation but only for repos that have ++ // been fully initialized. Check for common root files that indicate a ++ // real repo, not an empty dir created by module extensions before the ++ // repository rule has had a chance to run. ++ if (repoRoot.getChild("BUILD").exists() || repoRoot.getChild("BUILD.bazel").exists() ++ || repoRoot.getChild("WORKSPACE").exists() || repoRoot.getChild("WORKSPACE.bazel").exists()) { return RepositoryDirectoryValue.builder() .setPath(repoRoot) - .setDigest(markerHash) @@ -30,8 +34,6 @@ index 53e6494656..22261cd268 100644 .build(); } } - - diff --git a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java index 649647c5f2..64d05b530c 100644 --- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java @@ -43,4 +45,4 @@ index 649647c5f2..64d05b530c 100644 - builder.environment().clear(); builder.environment().putAll(params.getEnv()); } - + From 1de1c2d2c805ae4f325e8a59240963829c93fb52 Mon Sep 17 00:00:00 2001 From: Samuel Ainsworth Date: Sat, 21 Feb 2026 11:32:36 -0500 Subject: [PATCH 2/2] xla: add aarch64-darwin support - Add cctools.libtool for darwin toolchain detection - Set macOS deployment target (11.0) to fix availability errors - Add per-platform fetchAttrs hash for aarch64-darwin - Remove badPlatforms now that darwin builds work --- pkgs/by-name/xl/xla/package.nix | 36 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/pkgs/by-name/xl/xla/package.nix b/pkgs/by-name/xl/xla/package.nix index af80d031e614..85be5651e6a8 100644 --- a/pkgs/by-name/xl/xla/package.nix +++ b/pkgs/by-name/xl/xla/package.nix @@ -1,6 +1,7 @@ { bazel_7, buildBazelPackage, + cctools, curl, double-conversion, fetchFromGitHub, @@ -18,6 +19,7 @@ python3, snappy, sqlite, + stdenv, which, zlib, }: @@ -71,7 +73,8 @@ in gitMinimal pythonEnv # necessary for some patchShebang'ing which - ]; + ] + ++ lib.optional stdenv.hostPlatform.isDarwin cctools.libtool; buildInputs = [ curl @@ -136,6 +139,14 @@ in "--host_cxxopt=cstdint" # Exclude mobile/iOS targets that have Bazel incompatibilities "--build_tag_filters=-mobile,-ios" + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + # Set macOS deployment target to suppress availability errors (e.g. + # futimens requires 10.13+) in both target and host-tool builds. + "--copt=-mmacosx-version-min=11.0" + "--host_copt=-mmacosx-version-min=11.0" + "--linkopt=-mmacosx-version-min=11.0" + "--host_linkopt=-mmacosx-version-min=11.0" ]; removeRulesCC = false; @@ -146,10 +157,16 @@ in removeLocal = false; fetchAttrs = { - sha256 = "sha256-OJfSqDlEC+yhWwwMwaD5HGvuHm8OWk+yQxmbH0/gZ88="; + sha256 = + { + x86_64-linux = "sha256-OJfSqDlEC+yhWwwMwaD5HGvuHm8OWk+yQxmbH0/gZ88="; + aarch64-darwin = "sha256-sKxtdgozCV1on1gd+bm8FKyFxP0u70Hs24OdLNA3jh0="; + } + .${stdenv.hostPlatform.system} or (throw "unsupported system: ${stdenv.hostPlatform.system}"); preInstall = '' rm -rf $bazelOut/external/{local_config_python,\@local_config_python.marker} rm -rf $bazelOut/external/{local_config_sh,\@local_config_sh.marker} + rm -rf $bazelOut/external/{local_config_xcode,\@local_config_xcode.marker} rm -rf $bazelOut/external/{local_execution_config_python,\@local_execution_config_python.marker} rm -rf $bazelOut/external/{local_jdk,\@local_jdk.marker} ''; @@ -187,18 +204,9 @@ in homepage = "https://github.com/openxla/xla"; license = lib.licenses.asl20; maintainers = with lib.maintainers; [ samuela ]; - platforms = lib.platforms.unix; - badPlatforms = [ - # ERROR: /build/output/external/local_config_cc/BUILD: no such target - # '@@local_config_cc//:cc-compiler-k8': target 'cc-compiler-k8' not declared in package '' - # defined by /build/output/external/local_config_cc/BUILD - "aarch64-linux" - - # Bazel fails to build on darwin: - # ERROR: no such package '@@bazel_tools~xcode_configure_extension~local_config_xcode//': - # BUILD file not found in directory '' of external repository @@bazel_tools~xcode_configure_extension~local_config_xcode. - # Add a BUILD file to a directory to mark it as a package. - lib.systems.inspect.patterns.isDarwin + platforms = [ + "x86_64-linux" + "aarch64-darwin" ]; }; }