summary refs log tree commit diff
diff options
context:
space:
mode:
authorUri Baghin <uri@canva.com>2023-04-05 12:59:54 +1000
committerUri Baghin <uri@canva.com>2023-04-05 12:59:54 +1000
commit440b4de588d950e7fcf7add3b049fb209f097367 (patch)
tree204dfe272acd0820a5c9e03621d99605621aa318
parent45306ddf55def3ca1303ebc9133c5ca6ab941fc2 (diff)
downloadnixpkgs-440b4de588d950e7fcf7add3b049fb209f097367.tar
nixpkgs-440b4de588d950e7fcf7add3b049fb209f097367.tar.gz
nixpkgs-440b4de588d950e7fcf7add3b049fb209f097367.tar.bz2
nixpkgs-440b4de588d950e7fcf7add3b049fb209f097367.tar.lz
nixpkgs-440b4de588d950e7fcf7add3b049fb209f097367.tar.xz
nixpkgs-440b4de588d950e7fcf7add3b049fb209f097367.tar.zst
nixpkgs-440b4de588d950e7fcf7add3b049fb209f097367.zip
buildBazelPackage: support multiple targets
-rw-r--r--pkgs/build-support/build-bazel-package/default.nix35
-rw-r--r--pkgs/development/python-modules/jaxlib/default.nix2
-rw-r--r--pkgs/development/python-modules/tensorflow-probability/default.nix2
-rw-r--r--pkgs/development/python-modules/tensorflow/default.nix2
-rw-r--r--pkgs/development/tools/bazel-watcher/default.nix2
-rw-r--r--pkgs/development/tools/language-servers/verible/default.nix2
-rw-r--r--pkgs/servers/http/envoy/default.nix2
7 files changed, 22 insertions, 25 deletions
diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix
index a3f331b23cb..ab2014ea6a6 100644
--- a/pkgs/build-support/build-bazel-package/default.nix
+++ b/pkgs/build-support/build-bazel-package/default.nix
@@ -10,7 +10,7 @@ args@{
 , bazelBuildFlags ? []
 , bazelTestFlags ? []
 , bazelFetchFlags ? []
-, bazelTarget
+, bazelTargets
 , bazelTestTargets ? []
 , buildAttrs
 , fetchAttrs
@@ -69,11 +69,11 @@ let
     '';
 in
 stdenv.mkDerivation (fBuildAttrs // {
-  inherit name bazelFlags bazelBuildFlags bazelTestFlags bazelFetchFlags bazelTarget bazelTestTargets;
+  inherit name bazelFlags bazelBuildFlags bazelTestFlags bazelFetchFlags bazelTargets bazelTestTargets;
 
   deps = stdenv.mkDerivation (fFetchAttrs // {
     name = "${name}-deps.tar.gz";
-    inherit bazelFlags bazelBuildFlags bazelTestFlags bazelFetchFlags bazelTarget bazelTestTargets;
+    inherit bazelFlags bazelBuildFlags bazelTestFlags bazelFetchFlags bazelTargets bazelTestTargets;
 
     impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ fFetchAttrs.impureEnvVars or [];
 
@@ -94,21 +94,18 @@ stdenv.mkDerivation (fBuildAttrs // {
     buildPhase = fFetchAttrs.buildPhase or ''
       runHook preBuild
 
-      # See footnote called [USER and BAZEL_USE_CPP_ONLY_TOOLCHAIN variables].
-      # We disable multithreading for the fetching phase since it can lead to timeouts with many dependencies/threads:
-      # https://github.com/bazelbuild/bazel/issues/6502
-      BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 \
-      USER=homeless-shelter \
-      bazel \
-        --batch \
-        --output_base="$bazelOut" \
-        --output_user_root="$bazelUserRoot" \
-        ${if fetchConfigured then "build --nobuild" else "fetch"} \
-        --loading_phase_threads=1 \
-        $bazelFlags \
-        $bazelFetchFlags \
-        ${bazelTarget} \
-        ${lib.strings.concatStringsSep " " bazelTestTargets}
+      ${
+        bazelCmd {
+          cmd = if fetchConfigured then "build --nobuild" else "fetch";
+          additionalFlags = [
+            # We disable multithreading for the fetching phase since it can lead to timeouts with many dependencies/threads:
+            # https://github.com/bazelbuild/bazel/issues/6502
+            "--loading_phase_threads=1"
+            "$bazelFetchFlags"
+          ];
+          targets = bazelTargets ++ bazelTestTargets;
+        }
+      }
 
       runHook postBuild
     '';
@@ -232,7 +229,7 @@ stdenv.mkDerivation (fBuildAttrs // {
       bazelCmd {
         cmd = "build";
         additionalFlags = bazelBuildFlags;
-        targets = [bazelTarget];
+        targets = bazelTargets;
       }
     }
     runHook postBuild
diff --git a/pkgs/development/python-modules/jaxlib/default.nix b/pkgs/development/python-modules/jaxlib/default.nix
index ad48af827ee..ad0130d6462 100644
--- a/pkgs/development/python-modules/jaxlib/default.nix
+++ b/pkgs/development/python-modules/jaxlib/default.nix
@@ -138,7 +138,7 @@ let
       rm -f .bazelversion
     '';
 
-    bazelTarget = "//build:build_wheel";
+    bazelTargets = [ "//build:build_wheel" ];
 
     removeRulesCC = false;
 
diff --git a/pkgs/development/python-modules/tensorflow-probability/default.nix b/pkgs/development/python-modules/tensorflow-probability/default.nix
index b85eea44435..7bf73dff28d 100644
--- a/pkgs/development/python-modules/tensorflow-probability/default.nix
+++ b/pkgs/development/python-modules/tensorflow-probability/default.nix
@@ -50,7 +50,7 @@ let
 
     bazel = bazel_6;
 
-    bazelTarget = ":pip_pkg";
+    bazelTargets = [ ":pip_pkg" ];
     LIBTOOL = lib.optionalString stdenv.isDarwin "${cctools}/bin/libtool";
 
     fetchAttrs = {
diff --git a/pkgs/development/python-modules/tensorflow/default.nix b/pkgs/development/python-modules/tensorflow/default.nix
index 4e7ae3ef570..b8306dff724 100644
--- a/pkgs/development/python-modules/tensorflow/default.nix
+++ b/pkgs/development/python-modules/tensorflow/default.nix
@@ -385,7 +385,7 @@ let
     ]
     ++ lib.optionals (mklSupport) [ "--config=mkl" ];
 
-    bazelTarget = "//tensorflow/tools/pip_package:build_pip_package //tensorflow/tools/lib_package:libtensorflow";
+    bazelTargets = [ "//tensorflow/tools/pip_package:build_pip_package //tensorflow/tools/lib_package:libtensorflow" ];
 
     removeRulesCC = false;
     # Without this Bazel complaints about sandbox violations.
diff --git a/pkgs/development/tools/bazel-watcher/default.nix b/pkgs/development/tools/bazel-watcher/default.nix
index 38ea03d9f95..906403dcd1d 100644
--- a/pkgs/development/tools/bazel-watcher/default.nix
+++ b/pkgs/development/tools/bazel-watcher/default.nix
@@ -45,7 +45,7 @@ buildBazelPackage rec {
   bazel = bazel_5;
   bazelFlags = [ "--override_repository=rules_proto=${rulesProto}" ];
   bazelBuildFlags = lib.optionals stdenv.cc.isClang [ "--cxxopt=-x" "--cxxopt=c++" "--host_cxxopt=-x" "--host_cxxopt=c++" ];
-  bazelTarget = "//cmd/ibazel";
+  bazelTargets = [ "//cmd/ibazel" ];
 
   fetchConfigured = false; # we want to fetch all dependencies, regardless of the current system
   fetchAttrs = {
diff --git a/pkgs/development/tools/language-servers/verible/default.nix b/pkgs/development/tools/language-servers/verible/default.nix
index 91ac7b7bce0..85c5991a585 100644
--- a/pkgs/development/tools/language-servers/verible/default.nix
+++ b/pkgs/development/tools/language-servers/verible/default.nix
@@ -74,7 +74,7 @@ buildBazelPackage rec {
 
   bazel = bazel_4;
   removeRulesCC = false;
-  bazelTarget = ":install-binaries";
+  bazelTargets = [ ":install-binaries" ];
   bazelTestTargets = [ "//..." ];
   bazelBuildFlags = [
     "-c opt"
diff --git a/pkgs/servers/http/envoy/default.nix b/pkgs/servers/http/envoy/default.nix
index db040f8a208..1d2c43467f8 100644
--- a/pkgs/servers/http/envoy/default.nix
+++ b/pkgs/servers/http/envoy/default.nix
@@ -140,7 +140,7 @@ buildBazelPackage rec {
   removeRulesCC = false;
   removeLocalConfigCc = true;
   removeLocal = false;
-  bazelTarget = "//source/exe:envoy-static";
+  bazelTargets = [ "//source/exe:envoy-static" ];
   bazelBuildFlags = [
     "-c opt"
     "--spawn_strategy=standalone"