about summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorJoao Neves <sevenjp@gmail.com>2020-02-25 18:40:13 +0100
committerProfpatsch <mail@profpatsch.de>2020-02-28 12:21:22 +0100
commit95c91cebf132c7057da5d7a69b9dc90de09c96cc (patch)
tree11e676db6330ae555451fe74374dc0887baad620 /pkgs/development
parentdd413d4c2d0fdbbf359b0a9005908fa4464f5e4f (diff)
downloadnixlib-95c91cebf132c7057da5d7a69b9dc90de09c96cc.tar
nixlib-95c91cebf132c7057da5d7a69b9dc90de09c96cc.tar.gz
nixlib-95c91cebf132c7057da5d7a69b9dc90de09c96cc.tar.bz2
nixlib-95c91cebf132c7057da5d7a69b9dc90de09c96cc.tar.lz
nixlib-95c91cebf132c7057da5d7a69b9dc90de09c96cc.tar.xz
nixlib-95c91cebf132c7057da5d7a69b9dc90de09c96cc.tar.zst
nixlib-95c91cebf132c7057da5d7a69b9dc90de09c96cc.zip
bazel: output correct binary name
From Bazel 2.0.0 onwards, Bazel looks for a binary named
`bazel-${version}-${os_arch}` if the project root contains a
`.bazelversion` file or the USE_BAZEL_VERSION environment
variable is set.

This change ensures we output a binary with the correct name
for the current version and OS/arch combination.
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/tools/build-managers/bazel/default.nix9
1 files changed, 6 insertions, 3 deletions
diff --git a/pkgs/development/tools/build-managers/bazel/default.nix b/pkgs/development/tools/build-managers/bazel/default.nix
index a1eb69ea7a54..2a784b30b322 100644
--- a/pkgs/development/tools/build-managers/bazel/default.nix
+++ b/pkgs/development/tools/build-managers/bazel/default.nix
@@ -106,6 +106,7 @@ let
   # and libraries path.
   # We prefetch it, patch it, and override it in a global bazelrc.
   system = if stdenv.hostPlatform.isDarwin then "darwin" else "linux";
+  arch = stdenv.hostPlatform.parsed.cpu.name;
 
   remote_java_tools = stdenv.mkDerivation {
     name = "remote_java_tools_${system}";
@@ -493,9 +494,11 @@ stdenv.mkDerivation rec {
     mkdir -p $out/bin
 
     # official wrapper scripts that searches for $WORKSPACE_ROOT/tools/bazel
-    # if it can’t find something in tools, it calls $out/bin/bazel-real
+    # if it can’t find something in tools, it calls $out/bin/bazel-{version}-{os_arch}
+    # The binary _must_ exist with this naming if your project contains a .bazelversion
+    # file.
     cp ./bazel_src/scripts/packages/bazel.sh $out/bin/bazel
-    mv ./bazel_src/output/bazel $out/bin/bazel-real
+    mv ./bazel_src/output/bazel $out/bin/bazel-${version}-${system}-${arch}
 
     # shell completion files
     mkdir -p $out/share/bash-completion/completions $out/share/zsh/site-functions
@@ -534,7 +537,7 @@ stdenv.mkDerivation rec {
     exec "$BAZEL_REAL" "$@"
     EOF
 
-    # second call succeeds because it defers to $out/bin/bazel-real
+    # second call succeeds because it defers to $out/bin/bazel-{version}-{os_arch}
     hello_test
   '';