summary refs log tree commit diff
path: root/pkgs/development/tools
diff options
context:
space:
mode:
authorCharles Strahan <charles@cstrahan.com>2017-09-28 16:49:01 -0400
committerCharles Strahan <charles@cstrahan.com>2017-09-28 16:51:32 -0400
commitb93ba5dcd7b66ac5efdb8d6b9c255c5e85e58bc7 (patch)
treeb793beadbb3b6a5fb3e9e5bd8492814965ca1d5a /pkgs/development/tools
parent12ac88af1d5eaea7ad08d9fdd3d293158b692b12 (diff)
downloadnixpkgs-b93ba5dcd7b66ac5efdb8d6b9c255c5e85e58bc7.tar
nixpkgs-b93ba5dcd7b66ac5efdb8d6b9c255c5e85e58bc7.tar.gz
nixpkgs-b93ba5dcd7b66ac5efdb8d6b9c255c5e85e58bc7.tar.bz2
nixpkgs-b93ba5dcd7b66ac5efdb8d6b9c255c5e85e58bc7.tar.lz
nixpkgs-b93ba5dcd7b66ac5efdb8d6b9c255c5e85e58bc7.tar.xz
nixpkgs-b93ba5dcd7b66ac5efdb8d6b9c255c5e85e58bc7.tar.zst
nixpkgs-b93ba5dcd7b66ac5efdb8d6b9c255c5e85e58bc7.zip
envoy: fix by reviving bazel 0.4
/cc #28643
Diffstat (limited to 'pkgs/development/tools')
-rw-r--r--pkgs/development/tools/build-managers/bazel/0.4.nix91
1 files changed, 91 insertions, 0 deletions
diff --git a/pkgs/development/tools/build-managers/bazel/0.4.nix b/pkgs/development/tools/build-managers/bazel/0.4.nix
new file mode 100644
index 00000000000..2137c5c1497
--- /dev/null
+++ b/pkgs/development/tools/build-managers/bazel/0.4.nix
@@ -0,0 +1,91 @@
+{ stdenv, fetchurl, jdk, zip, unzip, bash, makeWrapper, which }:
+
+stdenv.mkDerivation rec {
+
+  version = "0.4.5";
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/bazelbuild/bazel/;
+    description = "Build tool that builds code quickly and reliably";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ cstrahan philandstuff ];
+    platforms = platforms.linux;
+  };
+
+  name = "bazel-${version}";
+
+  src = fetchurl {
+    url = "https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-dist.zip";
+    sha256 = "0asmq3kxnl4326zhgh13mvcrc8jvmiswjj4ymrq0943q4vj7nwrb";
+  };
+
+  sourceRoot = ".";
+
+  postPatch = ''
+    for f in $(grep -l -r '#!/bin/bash'); do
+      substituteInPlace "$f" --replace '#!/bin/bash' '#!${bash}/bin/bash'
+    done
+    for f in \
+      src/main/java/com/google/devtools/build/lib/analysis/CommandHelper.java \
+      src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfiguration.java \
+      src/main/java/com/google/devtools/build/lib/bazel/rules/sh/BazelShRuleClasses.java \
+      src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java \
+      ; do
+      substituteInPlace "$f" --replace /bin/bash ${bash}/bin/bash
+    done
+  '';
+
+  buildInputs = [
+    stdenv.cc
+    stdenv.cc.cc.lib
+    jdk
+    zip
+    unzip
+    makeWrapper
+    which
+  ];
+
+  # These must be propagated since the dependency is hidden in a compressed
+  # archive.
+
+  propagatedBuildInputs = [
+    bash
+  ];
+
+  # If TMPDIR is in the unpack dir we run afoul of blaze's infinite symlink
+  # detector (see com.google.devtools.build.lib.skyframe.FileFunction).
+  # Change this to $(mktemp -d) as soon as we figure out why.
+
+  buildPhase = ''
+    export TMPDIR=/tmp
+    ./compile.sh
+    ./output/bazel --output_user_root=/tmp/.bazel build //scripts:bash_completion \
+      --spawn_strategy=standalone \
+      --genrule_strategy=standalone
+    cp bazel-bin/scripts/bazel-complete.bash output/
+  '';
+
+  # Build the CPP and Java examples to verify that Bazel works.
+
+  doCheck = true;
+  checkPhase = ''
+    export TEST_TMPDIR=$(pwd)
+    ./output/bazel test --test_output=errors \
+        examples/cpp:hello-success_test \
+        examples/java-native/src/test/java/com/example/myproject:hello
+  '';
+
+  # Bazel expects gcc and java to be in the path.
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mv output/bazel $out/bin
+    wrapProgram "$out/bin/bazel" --prefix PATH : "${stdenv.cc}/bin:${jdk}/bin"
+    mkdir -p $out/share/bash-completion/completions $out/share/zsh/site-functions
+    mv output/bazel-complete.bash $out/share/bash-completion/completions/
+    cp scripts/zsh_completion/_bazel $out/share/zsh/site-functions/
+  '';
+
+  dontStrip = true;
+  dontPatchELF = true;
+}