tools/bazel: short-circuit wrapper when running inside nix-shell

Tested:
- `bazel` inside Nix shell.
- `tools/bazel info` inside Nix shell.
- `tools/bazel info` outside Nix shell.
-  `nix-shell -p bazelisk --run 'bazelisk info'` outside Nix shell.

Change-Id: I6a6a696430ea12d0bd61db56f13af596cf0a6729
Reviewed-on: https://review.monogon.dev/c/monogon/+/4405
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/tools/bazel b/tools/bazel
index 1ff2694..78e4624 100755
--- a/tools/bazel
+++ b/tools/bazel
@@ -17,7 +17,11 @@
 # to automagically switch into the nix-shell. Otherwise complain and
 # exit.
 if [[ -z "${BAZEL_REAL:-}" ]]; then
-  if [[ -x $(command -v nix-shell) ]]; then
+  # If we are already in the nix shell, we just set BAZEL_REAL and continue
+  # regular execution. Bazel will be in PATH.
+  if [[ -n "${MONOGON_NIXOS:-}" ]]; then
+    BAZEL_REAL="$(command -v bazel)"
+  elif [[ -x $(command -v nix-shell) ]]; then
     echo "BAZEL_REAL is not set and nix-shell is available, overriding to nix-shell" >&2
     USE_NIX_SHELL=yes
   else