From 7e3140688664fb8d83c802673c36075c1d1d8db1 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Fri, 4 Jan 2019 18:05:03 +0100 Subject: [PATCH] bazel: greatly reduce time spent substituting, be smart which files Files inspected: 2756 -> 40 Total size of inspected files: 20M -> 1016K --- pkgs/development/tools/build-managers/bazel/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/tools/build-managers/bazel/default.nix b/pkgs/development/tools/build-managers/bazel/default.nix index 9aff59f3497..e91c8e7f962 100644 --- a/pkgs/development/tools/build-managers/bazel/default.nix +++ b/pkgs/development/tools/build-managers/bazel/default.nix @@ -116,7 +116,10 @@ stdenv.mkDerivation rec { done ''; genericPatches = '' - find src/main/java/com/google/devtools -type f -print0 | while IFS="" read -r -d "" path; do + # substituteInPlace is rather slow, so prefilter the files with grep + grep -rlZ /bin src/main/java/com/google/devtools | while IFS="" read -r -d "" path; do + # If you add more replacements here, you must change the grep above! + # Only files containing /bin are taken into account. substituteInPlace "$path" \ --replace /bin/bash ${customBash}/bin/bash \ --replace /usr/bin/env ${coreutils}/bin/env \