Skip to content

Commit e9d7e18

Browse files
abueideclaude
andcommitted
fix(android,ios): replace IN_NIX_SHELL with DEVBOX_PURE_SHELL for pure mode detection
IN_NIX_SHELL is a Nix-native variable that devbox never sets. Replace all references with DEVBOX_PURE_SHELL, which devbox sets to "1" when running with --pure. Also add REUSE_EMU and REUSE_SIM env var overrides to allow simulator/emulator reuse while still running in pure mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7cb2f1d commit e9d7e18

16 files changed

Lines changed: 48 additions & 39 deletions

File tree

examples/android/tests/test-suite.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ processes:
3535
echo "[ANDROID-EMULATOR] Starting emulator..."
3636
device="${ANDROID_DEFAULT_DEVICE:-max}"
3737
38-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
38+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
3939
echo "Starting fresh Android emulator (pure mode): $device"
4040
android.sh emulator start --pure "$device"
4141
else
@@ -90,7 +90,7 @@ processes:
9090
# Cleanup - stop everything in pure mode, keep running in dev mode
9191
cleanup-app:
9292
command: |
93-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
93+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
9494
echo "Cleaning up (pure mode)..."
9595
android.sh app stop || true
9696
android.sh emulator stop || true

examples/ios/tests/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ devbox run test:e2e
5050

5151
```bash
5252
devbox run --pure test:e2e
53-
# or in CI:
54-
IN_NIX_SHELL=pure devbox run test:e2e
5553
```
5654

57-
The test suite automatically detects `IN_NIX_SHELL=pure` and adjusts cleanup behavior.
55+
The test suite automatically detects `DEVBOX_PURE_SHELL=1` (set by `--pure`) and adjusts cleanup behavior.
5856

5957
## Copy to Your Project
6058

@@ -217,7 +215,7 @@ deploy-app (phase 4) ─────┘ depends on simulator ready
217215
218216
verify-app-running (phase 5)
219217
220-
cleanup (phase 6) - conditional based on IN_NIX_SHELL
218+
cleanup (phase 6) - conditional based on DEVBOX_PURE_SHELL
221219
222220
summary (phase 7)
223221
```

examples/ios/tests/test-suite.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ processes:
2626
# Phase 3: Start simulator - depends on sync completing
2727
ios-simulator:
2828
command: |
29-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
29+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
3030
ios.sh simulator start --pure ${IOS_DEVICE}
3131
else
3232
ios.sh simulator start ${IOS_DEVICE}
@@ -97,7 +97,7 @@ processes:
9797
# Cleanup - stop everything in pure mode, keep running in dev mode
9898
cleanup:
9999
command: |
100-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
100+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
101101
echo "Cleaning up (pure mode)..."
102102
ios.sh app stop || true
103103
ios.sh simulator stop

examples/react-native/tests/test-suite-all-e2e.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ processes:
6767
echo "[ANDROID-EMULATOR] Starting emulator..."
6868
device="${ANDROID_DEFAULT_DEVICE:-max}"
6969
70-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
70+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
7171
echo "Starting fresh Android emulator (pure mode): $device"
7272
android.sh emulator start --pure "$device"
7373
else
@@ -91,7 +91,7 @@ processes:
9191
# Phase 4b: Start iOS simulator (parallel with Android)
9292
ios-simulator:
9393
command: |
94-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
94+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
9595
ios.sh simulator start --pure ${IOS_DEVICE}
9696
else
9797
ios.sh simulator start ${IOS_DEVICE}
@@ -253,7 +253,7 @@ processes:
253253
echo "Stopping Metro bundler..."
254254
metro.sh stop all || true
255255
256-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
256+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
257257
echo "Cleaning up (pure mode)..."
258258
259259
# Cleanup Android

examples/react-native/tests/test-suite-android-e2e.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ processes:
4747
echo "[ANDROID-EMULATOR] Starting emulator..."
4848
device="${ANDROID_DEFAULT_DEVICE:-max}"
4949
50-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
50+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
5151
echo "Starting fresh Android emulator (pure mode): $device"
5252
android.sh emulator start --pure "$device"
5353
else
@@ -139,7 +139,7 @@ processes:
139139
echo "Stopping Metro bundler..."
140140
metro.sh stop android || true
141141
142-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
142+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
143143
echo "Cleaning up (pure mode)..."
144144
android.sh app stop || true
145145
android.sh emulator stop || true

examples/react-native/tests/test-suite-ios-e2e.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ processes:
4444
# Phase 4: Start simulator
4545
ios-simulator:
4646
command: |
47-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
47+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
4848
ios.sh simulator start --pure ${IOS_DEVICE}
4949
else
5050
ios.sh simulator start ${IOS_DEVICE}
@@ -147,7 +147,7 @@ processes:
147147
echo "Stopping Metro bundler..."
148148
metro.sh stop ios || true
149149
150-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
150+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
151151
echo "Cleaning up (pure mode)..."
152152
ios.sh app stop || true
153153
ios.sh simulator stop

plugins/android/REFERENCE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ Use in `devbox.json`:
9393
- `devbox run --pure android.sh emulator start [--pure] [device]`
9494
- `--pure`: Start fresh emulator with wiped data (clean Android OS state for deterministic tests)
9595
- Without `--pure`: Reuses existing emulator if running (faster for development, preserves data)
96-
- Auto-detects pure mode when `IN_NIX_SHELL=pure` or `DEVBOX_PURE_SHELL=1`
96+
- Auto-detects pure mode when `DEVBOX_PURE_SHELL=1` (set by `devbox run --pure`)
97+
- `REUSE_EMU=1`: Override pure mode to reuse existing emulator (e.g., `devbox run --pure -e REUSE_EMU=1`)
9798
- `devbox run --pure android.sh emulator stop`
9899
- `devbox run --pure android.sh emulator ready`
99100
- Silent readiness probe: exit 0 if emulator is booted, exit 1 if not

plugins/android/virtenv/scripts/user/android.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,16 @@ case "$command_name" in
345345
done
346346

347347
# Auto-detect pure mode from devbox environment
348-
if [ "${IN_NIX_SHELL:-}" = "pure" ] || [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
348+
if [ "${DEVBOX_PURE_SHELL:-}" = "1" ]; then
349349
pure_mode=1
350350
fi
351351

352+
# Allow overriding pure mode to reuse existing emulator
353+
# Usage: devbox run --pure -e REUSE_EMU=1 android.sh emulator start
354+
if [ "${REUSE_EMU:-}" = "1" ]; then
355+
pure_mode=0
356+
fi
357+
352358
# Layer 3 orchestration: setup AVDs first, then start emulator
353359
if ! command -v android_setup_avds >/dev/null 2>&1; then
354360
echo "ERROR: android_setup_avds function not available" >&2

plugins/ios/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ When running with `--pure`, the plugin:
121121
- Cleans up test simulators after completion
122122
- Ensures reproducible CI environment
123123

124-
The `IN_NIX_SHELL` environment variable is automatically set by devbox:
125-
- `IN_NIX_SHELL=impure` - Normal mode
126-
- `IN_NIX_SHELL=pure` - Pure mode (set by `--pure` flag)
124+
The `DEVBOX_PURE_SHELL` environment variable is automatically set by devbox when using the `--pure` flag. Scripts auto-detect this to determine whether to create fresh, isolated simulators.
127125

128126
## Xcode Discovery
129127

plugins/ios/REFERENCE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ ios.sh simulator start [--pure] [device]
6666
- Otherwise uses `IOS_DEFAULT_DEVICE`
6767
- Boots simulator if not already running
6868
- `--pure`: Creates a fresh, isolated test simulator with clean state (for deterministic tests)
69-
- Auto-detects pure mode when `IN_NIX_SHELL=pure` or `DEVBOX_PURE_SHELL=1`
69+
- Auto-detects pure mode when `DEVBOX_PURE_SHELL=1` (set by `devbox run --pure`)
70+
- `REUSE_SIM=1`: Override pure mode to reuse existing simulator (e.g., `devbox run --pure -e REUSE_SIM=1`)
7071
- Saves simulator UDID to `$IOS_RUNTIME_DIR/${SUITE_NAME:-default}/simulator-udid.txt`
7172
- In pure mode, test simulator name includes suite label for isolation (e.g., `"iPhone 17 (iOS 26.2) Test-ios-e2e"`)
7273

0 commit comments

Comments
 (0)