Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions scripts/env_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,25 @@ setup_lima() {
exit 1
fi

LIMA_CPUS="${LIMA_CPUS:-$( nproc )}"
LIMA_MEMORY="${LIMA_MEMORY:-$( free -g | awk '/^Mem:/ {print $2-2 }' )}"
# Detect CPU count (cross-platform)
if command -v nproc &>/dev/null; then
LIMA_CPUS="${LIMA_CPUS:-$( nproc )}"
elif [[ "$OSTYPE" == "darwin"* ]]; then
LIMA_CPUS="${LIMA_CPUS:-$( sysctl -n hw.ncpu )}"
else
LIMA_CPUS="${LIMA_CPUS:-2}" # Fallback
fi

# Detect memory (cross-platform)
if command -v free &>/dev/null; then
LIMA_MEMORY="${LIMA_MEMORY:-$( free -g | awk '/^Mem:/ {print $2-2 }' )}"
elif [[ "$OSTYPE" == "darwin"* ]]; then
# sysctl returns bytes, convert to GB and subtract 2GB
mem_gb=$(($(sysctl -n hw.memsize) / 1024 / 1024 / 1024 - 2))
LIMA_MEMORY="${LIMA_MEMORY:-$mem_gb}"
else
LIMA_MEMORY="${LIMA_MEMORY:-4}" # Fallback
fi

# Create VM if it doesn't exist
if ! limactl list "$LIMA_VM" > /dev/null 2>&1; then
Expand Down