# Parse claudebox flags SKIP_AUDIT=false DRY_RUN=false CHECK_MODE=false SHELL_MODE=false CLAUDE_ARGS=() while (( $# > 0 )); do case "$1" in --yes|-y) SKIP_AUDIT=true ;; --dry-run) DRY_RUN=true ;; --check) CHECK_MODE=true ;; --shell) SHELL_MODE=true ;; --) shift; CLAUDE_ARGS+=("$@"); break ;; *) CLAUDE_ARGS+=("$1") ;; esac shift done # SANDBOX_PATH is injected by flake.nix via makeBinPath (only runtimeInputs, no host PATH) # Resolve binary paths from runtimeInputs SANDBOX_BASH="$(command -v bash)" CLAUDE_BIN="$(command -v claude)" # Record CWD CWD=$(pwd) # Ensure ~/.claudebox exists mkdir -p "$HOME/.claudebox" # Generate minimal .gitconfig (D-05) GIT_NAME=$(git config --global user.name 2>/dev/null || echo "Claude User") GIT_EMAIL=$(git config --global user.email 2>/dev/null || echo "claude@localhost") GITCONFIG_TMP=$(mktemp) trap 'rm -f "$GITCONFIG_TMP"' EXIT cat > "$GITCONFIG_TMP" <&2 exit 0 fi # exec bwrap (SAND-04 through SAND-15, UX-06, D-01) exec bwrap \ --clearenv \ "${ENV_ARGS[@]}" \ --tmpfs / \ --proc /proc \ --dev /dev \ --tmpfs /tmp \ --ro-bind /nix/store /nix/store \ --bind /nix/var/nix /nix/var/nix \ --ro-bind /etc/resolv.conf /etc/resolv.conf \ --ro-bind /etc/ssl /etc/ssl \ --ro-bind /etc/static /etc/static \ --ro-bind /etc/passwd /etc/passwd \ --ro-bind /etc/group /etc/group \ --ro-bind /etc/hosts /etc/hosts \ --ro-bind /etc/nsswitch.conf /etc/nsswitch.conf \ --ro-bind /etc/nix /etc/nix \ --symlink "$(readlink -f "$(command -v env)")" /usr/bin/env \ --tmpfs "$HOME" \ --bind "$HOME/.claudebox" "$HOME/.claude" \ --ro-bind "$GITCONFIG_TMP" "$HOME/.gitconfig" \ --bind "$CWD" "$CWD" \ --chdir "$CWD" \ -- "${SANDBOX_CMD[@]}"