# Lima VM configuration for OpenClaw Sandbox
# AUTO-GENERATED by sandbox CLI - do not edit manually
# https://lima-vm.io/docs/reference/yaml/

vmType: "vz"

images:
  - location: "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
    arch: "x86_64"
  - location: "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-arm64.img"
    arch: "aarch64"

cpus: {{ ctx.vm_cpus }}
memory: "{{ ctx.vm_memory }}"
disk: "{{ ctx.vm_disk }}"

ssh:
  localPort: 0
  loadDotSSHPubKeys: true

# Rosetta for x86_64 emulation on Apple Silicon
vmOpts:
  vz:
    rosetta:
      enabled: true
      binfmt: true

mounts:
{% for mount in ctx.mounts %}
  - location: "{{ mount.location }}"
    mountPoint: "{{ mount.mount_point }}"
    writable: {{ "true" if mount.writable else "false" }}
{% endfor %}

# Note: Using default user-mode networking (no socket_vmnet required)
# VM can access internet, host can access VM via port forwards

containerd:
  system: false
  user: false

provision:
  - mode: system
    script: |
      #!/bin/bash
      set -eux -o pipefail
      apt-get update
      apt-get install -y \
        curl \
        git \
        jq \
        build-essential \
        python3 \
        python3-pip \
        ca-certificates \
        gnupg
      apt-get clean
      rm -rf /var/lib/apt/lists/*

  - mode: user
    script: |
      #!/bin/bash
      set -eux -o pipefail
      mkdir -p ~/.openclaw
      mkdir -p ~/.local/bin
      echo "OpenClaw sandbox VM provisioned successfully"

portForwards:
{% for pf in ctx.port_forwards %}
  - guestPort: {{ pf.guest_port }}
    hostPort: {{ pf.host_port }}
    proto: {{ pf.proto }}
{% endfor %}

env:
  OPENCLAW_SANDBOX: "true"

message: |
  OpenClaw Sandbox VM is ready!

  Gateway port 18789 is forwarded to host.

  To stop: limactl stop openclaw-sandbox
  To delete: sandbox destroy
