@@ -125,9 +125,11 @@ stdenv.mkDerivation rec {
125125
126126 genericPatches = ''
127127 # Substitute python's stub shebang to plain python path. (see TODO add pr URL)
128+ # See also `postFixup` where python is added to $out/nix-support
128129 substituteInPlace src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt\
129130 --replace "/usr/bin/env python" "${python}/bin/python" \
130131 --replace "NIX_STORE_PYTHON_PATH" "${python}/bin/python" \
132+
131133 # substituteInPlace is rather slow, so prefilter the files with grep
132134 grep -rlZ /bin src/main/java/com/google/devtools | while IFS="" read -r -d "" path; do
133135 # If you add more replacements here, you must change the grep above!
@@ -262,7 +264,10 @@ stdenv.mkDerivation rec {
262264 # Save paths to hardcoded dependencies so Nix can detect them.
263265 postFixup = ''
264266 mkdir -p $out/nix-support
265− echo "${customBash} ${defaultShellPath}" > $out/nix-support/depends
267+ echo "${customBash} ${defaultShellPath}" >> $out/nix-support/depends
268+ # The templates get tar’d up into a .jar,
269+ # so nix can’t detect python is needed in the runtime closure
270+ echo "${python}" >> $out/nix-support/depends
266271 '';
267272
268273 dontStrip = true;