diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix index 07d37451ddf..26f44b922cd 100644 --- a/pkgs/build-support/build-bazel-package/default.nix +++ b/pkgs/build-support/build-bazel-package/default.nix @@ -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 '';