diff --git a/pkgs/development/tools/build-managers/bazel/0.4.nix b/pkgs/development/tools/build-managers/bazel/0.4.nix index 2137c5c1497..bd61bb00ee1 100644 --- a/pkgs/development/tools/build-managers/bazel/0.4.nix +++ b/pkgs/development/tools/build-managers/bazel/0.4.nix @@ -1,4 +1,8 @@ -{ stdenv, fetchurl, jdk, zip, unzip, bash, makeWrapper, which }: +{ stdenv, lib, fetchurl, jdk, zip, unzip, bash, makeWrapper, which +# Always assume all markers valid (don't redownload dependencies). +# Also, don't clean up environment variables. +, enableNixHacks ? false +}: stdenv.mkDerivation rec { @@ -21,6 +25,8 @@ stdenv.mkDerivation rec { sourceRoot = "."; + patches = lib.optional enableNixHacks ./nix-hacks.patch; + postPatch = '' for f in $(grep -l -r '#!/bin/bash'); do substituteInPlace "$f" --replace '#!/bin/bash' '#!${bash}/bin/bash' diff --git a/pkgs/development/tools/build-managers/bazel/nix-hacks.patch b/pkgs/development/tools/build-managers/bazel/nix-hacks.patch new file mode 100644 index 00000000000..563fe635e6b --- /dev/null +++ b/pkgs/development/tools/build-managers/bazel/nix-hacks.patch @@ -0,0 +1,51 @@ +diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java +index eafa09fb5..d2d5e40e8 100644 +--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java ++++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java +@@ -287,21 +287,8 @@ public final class RepositoryDelegatorFunction implements SkyFunction { + markerData.put(key, value); + } + } +- boolean result = false; +- if (markerRuleKey.equals(ruleKey)) { +- result = handler.verifyMarkerData(rule, markerData, env); +- if (env.valuesMissing()) { +- return null; +- } +- } + +- if (result) { +- return new Fingerprint().addString(content).digestAndReset(); +- } else { +- // So that we are in a consistent state if something happens while fetching the repository +- markerPath.delete(); +- return null; +- } ++ return new Fingerprint().addString(content).digestAndReset(); + + } catch (IOException e) { + throw new RepositoryFunctionException(e, Transience.TRANSIENT); +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 a7ebc8f7a..40f2049fa 100644 +--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java ++++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java +@@ -129,7 +129,6 @@ public class JavaSubprocessFactory implements SubprocessFactory { + ProcessBuilder builder = new ProcessBuilder(); + builder.command(params.getArgv()); + if (params.getEnv() != null) { +- builder.environment().clear(); + builder.environment().putAll(params.getEnv()); + } + +diff --git a/src/main/java/com/google/devtools/build/lib/worker/Worker.java b/src/main/java/com/google/devtools/build/lib/worker/Worker.java +index 0268d1b2b..637364657 100644 +--- a/src/main/java/com/google/devtools/build/lib/worker/Worker.java ++++ b/src/main/java/com/google/devtools/build/lib/worker/Worker.java +@@ -77,7 +77,6 @@ class Worker { + new ProcessBuilder(command) + .directory(workDir.getPathFile()) + .redirectError(Redirect.appendTo(logFile.getPathFile())); +- processBuilder.environment().clear(); + processBuilder.environment().putAll(workerKey.getEnv()); + + this.process = processBuilder.start();