Files
foxhunt/.devcontainer/init-home.sh
jgrusewski 30516764c6 feat(devcontainer): add init-home.sh for PVC bootstrap
Links cargo binaries, creates sccache dir, and writes default .zshrc
on first boot. No-op on subsequent sessions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 21:12:42 +01:00

26 lines
873 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Bootstrap cargo into PVC-backed home if not already present
if [ ! -d "$HOME/.cargo/bin" ]; then
echo "[init-home] First run: linking cargo toolchain..."
mkdir -p "$HOME/.cargo/bin"
# Copy cargo config and link binaries from shared rustup
for bin in /opt/cargo/bin/*; do
ln -sf "$bin" "$HOME/.cargo/bin/$(basename "$bin")"
done
echo "[init-home] Cargo toolchain linked."
fi
# Ensure sccache cache dir exists
mkdir -p "${SCCACHE_DIR:-$HOME/.cache/sccache}"
# Default .zshrc if none exists (oh-my-zsh is in the image, config in PVC)
if [ ! -f "$HOME/.zshrc" ]; then
cp /home/dev/.oh-my-zsh/templates/zshrc.zsh-template "$HOME/.zshrc" 2>/dev/null || true
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> "$HOME/.zshrc"
echo 'export SQLX_OFFLINE=true' >> "$HOME/.zshrc"
fi
echo "[init-home] Ready."