build-bazel-package: prefix bazel with the USER variable

Bazel computes the default value of output_user_root before parsing the
flag[0]. The computation of the default value involves getting the $USER
from the environment. I don't have that variable when building with
sandbox enabled.

[0]: 9323c57607/src/main/cpp/startup_options.cc (L123-L124)
This commit is contained in:
Wael M. Nasreddine 2018-09-10 22:30:22 -07:00
parent e3654421d3
commit 18aa9b0b65
No known key found for this signature in database
GPG key ID: 82AE0A31B33CEFCF

View file

@ -25,7 +25,13 @@ in stdenv.mkDerivation (fBuildAttrs // {
buildPhase = fFetchAttrs.buildPhase or ''
runHook preBuild
bazel --output_base="$bazelOut" --output_user_root="$bazelUserRoot" fetch $bazelFlags $bazelTarget
# Bazel computes the default value of output_user_root before parsing the
# flag. The computation of the default value involves getting the $USER
# from the environment. I don't have that variable when building with
# sandbox enabled. Code here
# https://github.com/bazelbuild/bazel/blob/9323c57607d37f9c949b60e293b573584906da46/src/main/cpp/startup_options.cc#L123-L124
#
USER=homeless-shelter bazel --output_base="$bazelOut" --output_user_root="$bazelUserRoot" fetch $bazelFlags $bazelTarget
runHook postBuild
'';