about summary refs log tree commit diff
path: root/pkgs/development/tools/build-managers
diff options
context:
space:
mode:
authorWael Nasreddine <wael.nasreddine@gmail.com>2019-06-13 07:12:38 -0700
committerProfpatsch <philip.patsch@tweag.io>2019-06-13 16:12:37 +0200
commitbad7bc44db55912ca27a62362ed71f4dd6721f9c (patch)
treeb4f18fd8f5e7d5d1f88403a467d671702688f813 /pkgs/development/tools/build-managers
parent910b1795067bf7d5c99beb58fb0fb47a51995bda (diff)
downloadnixlib-bad7bc44db55912ca27a62362ed71f4dd6721f9c.tar
nixlib-bad7bc44db55912ca27a62362ed71f4dd6721f9c.tar.gz
nixlib-bad7bc44db55912ca27a62362ed71f4dd6721f9c.tar.bz2
nixlib-bad7bc44db55912ca27a62362ed71f4dd6721f9c.tar.lz
nixlib-bad7bc44db55912ca27a62362ed71f4dd6721f9c.tar.xz
nixlib-bad7bc44db55912ca27a62362ed71f4dd6721f9c.tar.zst
nixlib-bad7bc44db55912ca27a62362ed71f4dd6721f9c.zip
bazel: fix nix-hacks.patch with the latest version of Bazel (#63052)
* bazel: add a failing test for nix-hacks

* fix the patch
Diffstat (limited to 'pkgs/development/tools/build-managers')
-rw-r--r--pkgs/development/tools/build-managers/bazel/bash-tools-test.nix1
-rw-r--r--pkgs/development/tools/build-managers/bazel/default.nix24
-rw-r--r--pkgs/development/tools/build-managers/bazel/nix-hacks.patch54
-rw-r--r--pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix1
4 files changed, 45 insertions, 35 deletions
diff --git a/pkgs/development/tools/build-managers/bazel/bash-tools-test.nix b/pkgs/development/tools/build-managers/bazel/bash-tools-test.nix
index ae90ae0fbf77..fa6b310ce618 100644
--- a/pkgs/development/tools/build-managers/bazel/bash-tools-test.nix
+++ b/pkgs/development/tools/build-managers/bazel/bash-tools-test.nix
@@ -31,6 +31,7 @@ let
 
   testBazel = bazelTest {
     name = "bazel-test-bash-tools";
+    bazelPkg = bazel;
     inherit workspaceDir;
 
     bazelScript = ''
diff --git a/pkgs/development/tools/build-managers/bazel/default.nix b/pkgs/development/tools/build-managers/bazel/default.nix
index 16c914349e78..1ea0fc049ba8 100644
--- a/pkgs/development/tools/build-managers/bazel/default.nix
+++ b/pkgs/development/tools/build-managers/bazel/default.nix
@@ -122,7 +122,7 @@ stdenv.mkDerivation rec {
 
       # bazel wants to extract itself into $install_dir/install every time it runs,
       # so let’s do that only once.
-      extracted =
+      extracted = bazelPkg:
         let install_dir =
           # `install_base` field printed by `bazel info`, minus the hash.
           # yes, this path is kinda magic. Sorry.
@@ -130,7 +130,7 @@ stdenv.mkDerivation rec {
         in runLocal "bazel-extracted-homedir" { passthru.install_dir = install_dir; } ''
             export HOME=$(mktemp -d)
             touch WORKSPACE # yeah, everything sucks
-            install_base="$(${bazel}/bin/bazel info | grep install_base)"
+            install_base="$(${bazelPkg}/bin/bazel info | grep install_base)"
             # assert it’s actually below install_dir
             [[ "$install_base" =~ ${install_dir} ]] \
               || (echo "oh no! $install_base but we are \
@@ -138,21 +138,23 @@ stdenv.mkDerivation rec {
             cp -R ${install_dir} $out
           '';
 
-      bazelTest = { name, bazelScript, workspaceDir }:
-        runLocal name {} (
+      bazelTest = { name, bazelScript, workspaceDir, bazelPkg }:
+        let
+          be = extracted bazelPkg;
+        in runLocal name {} (
           # skip extraction caching on Darwin, because nobody knows how Darwin works
           (lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
             # set up home with pre-unpacked bazel
             export HOME=$(mktemp -d)
-            mkdir -p ${extracted.install_dir}
-            cp -R ${extracted}/install ${extracted.install_dir}
+            mkdir -p ${be.install_dir}
+            cp -R ${be}/install ${be.install_dir}
 
             # https://stackoverflow.com/questions/47775668/bazel-how-to-skip-corrupt-installation-on-centos6
             # Bazel checks whether the mtime of the install dir files
             # is >9 years in the future, otherwise it extracts itself again.
             # see PosixFileMTime::IsUntampered in src/main/cpp/util
             # What the hell bazel.
-            ${lr}/bin/lr -0 -U ${extracted.install_dir} | ${xe}/bin/xe -N0 -0 touch --date="9 years 6 months" {}
+            ${lr}/bin/lr -0 -U ${be.install_dir} | ${xe}/bin/xe -N0 -0 touch --date="9 years 6 months" {}
           '')
           +
           ''
@@ -165,9 +167,13 @@ stdenv.mkDerivation rec {
             touch $out
           '');
 
+      bazelWithNixHacks = bazel.override { enableNixHacks = true; };
     in {
-      pythonBinPath = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; };
-      bashTools = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; };
+      pythonBinPathWithoutNixHacks = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; };
+      bashToolsWithoutNixHacks = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; };
+
+      pythonBinPathWithNixHacks = callPackage ./python-bin-path-test.nix{ inherit runLocal bazelTest; bazel = bazelWithNixHacks; };
+      bashToolsWithNixHacks = callPackage ./bash-tools-test.nix { inherit runLocal bazelTest; bazel = bazelWithNixHacks; };
     };
 
   name = "bazel-${version}";
diff --git a/pkgs/development/tools/build-managers/bazel/nix-hacks.patch b/pkgs/development/tools/build-managers/bazel/nix-hacks.patch
index da3f6248f220..f58be89fabc1 100644
--- a/pkgs/development/tools/build-managers/bazel/nix-hacks.patch
+++ b/pkgs/development/tools/build-managers/bazel/nix-hacks.patch
@@ -1,33 +1,35 @@
 diff -Naur 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
---- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java	1980-01-01 00:00:00.000000000 -0500
-+++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java	2018-01-18 08:17:22.420459162 -0500
-@@ -287,21 +287,8 @@
-           markerData.put(key, value);
-         }
-       }
--      boolean result = false;
--      if (markerRuleKey.equals(ruleKey)) {
--        result = handler.verifyMarkerData(rule, markerData, env);
--        if (env.valuesMissing()) {
+--- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java	2019-06-12 20:39:37.420705161 -0700
++++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java	2019-06-12 20:44:18.894429744 -0700
+@@ -428,24 +428,7 @@
+       try {
+         content = FileSystemUtils.readContent(markerPath, StandardCharsets.UTF_8);
+         String markerRuleKey = readMarkerFile(content, markerData);
+-        boolean verified = false;
+-        if (Preconditions.checkNotNull(ruleKey).equals(markerRuleKey)
+-            && Objects.equals(
+-                markerData.get(MANAGED_DIRECTORIES_MARKER),
+-                this.markerData.get(MANAGED_DIRECTORIES_MARKER))) {
+-          verified = handler.verifyMarkerData(rule, markerData, env);
+-          if (env.valuesMissing()) {
+-            return null;
+-          }
+-        }
+-
+-        if (verified) {
+           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;
 -        }
--      }
- 
--      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);
+       } catch (IOException e) {
+         throw new RepositoryFunctionException(e, Transience.TRANSIENT);
+       }
 diff -Naur a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
---- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java	1980-01-01 00:00:00.000000000 -0500
-+++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java	2018-01-18 08:17:53.274877980 -0500
-@@ -129,7 +129,6 @@
+--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java	2019-06-12 20:39:37.538708196 -0700
++++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java	2019-06-12 20:44:18.863429602 -0700
+@@ -146,7 +146,6 @@
      ProcessBuilder builder = new ProcessBuilder();
      builder.command(params.getArgv());
      if (params.getEnv() != null) {
diff --git a/pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix b/pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix
index d2b95d79ff98..08bc642b6307 100644
--- a/pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix
+++ b/pkgs/development/tools/build-managers/bazel/python-bin-path-test.nix
@@ -41,6 +41,7 @@ let
   testBazel = bazelTest {
     name = "bazel-test-builtin-rules";
     inherit workspaceDir;
+    bazelPkg = bazel;
     bazelScript = ''
       ${bazel}/bin/bazel \
         run \