tools/run_bazel: allow running bazel inside nix-shell without entering
nix-shell does not support arguments for an application running inside
a FHS environment. This adds a workaround by keeping the command inside
an environment variable and executing it if set. If it doesnt exist, we
fall back to our bash shell.
Change-Id: I7fd53f9c14019179490af4b9af3b0b16b3d70297
Reviewed-on: https://review.monogon.dev/c/monogon/+/2066
Tested-by: Jenkins CI
Reviewed-by: Leopold Schabel <leo@monogon.tech>
diff --git a/shell.nix b/shell.nix
index 69e6ac4..2ae043c 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,3 +1,4 @@
+{ command ? "bash --noprofile --norc" }:
# If you're on NixOS, use me! `nix-shell --pure`.
with import (fetchTarball {
# nixpkgs 23.05 as of 2023/07/19
@@ -27,7 +28,12 @@
# stripped by (host_)action_env.
export BAZEL_SH=/bin/bash
- exec bash --noprofile --norc "$@"
+ # Allow passing a custom command via env since nix-shell doesn't support
+ # this yet: https://github.com/NixOS/nix/issues/534
+ if [ ! -n "$COMMAND" ]; then
+ COMMAND="bash --noprofile --norc"
+ fi
+ exec $COMMAND
'';
in
(pkgs.buildFHSUserEnv {