# A template to run ubuntu using device: default
# This template requires Lima v0.23.0 or later.
images:
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
- location: "https://cloud-images.ubuntu.com/releases/noble/release-20250313/ubuntu-24.04-server-cloudimg-amd64.img"
  arch: "x86_64"
  digest: "sha256:eacac65efe9e9bae0cbcb3f9d5c2b5e8c5313fa78a3bc401c3fb28b2d48cefc0"
- location: "https://cloud-images.ubuntu.com/releases/noble/release-20250313/ubuntu-24.04-server-cloudimg-arm64.img"
  arch: "aarch64"
  digest: "sha256:103f31c5a5b7f031a60ce3555c8fbd56317fd8ffbaaa7e17002879e6157d546d"
# Fallback to the latest release image.
# Hint: run `limactl prune` to invalidate the cache
- location: "https://cloud-images.ubuntu.com/releases/noble/release/ubuntu-24.04-server-cloudimg-amd64.img"
  arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/noble/release/ubuntu-24.04-server-cloudimg-arm64.img"
  arch: "aarch64"
mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true

vmType: "qemu"
audio:
  device: "default"

provision:
- mode: system
  script: |
    #!/bin/bash
    set -eux -o pipefail
    test -e /lib/modules/$(uname -r)/kernel/sound/pci/hda/snd-hda-intel.ko* && exit 0
    apt-get install -y linux-modules-extra-$(uname -r)
    modprobe snd-hda-intel
- mode: system
  script: |
    #!/bin/bash
    set -eux -o pipefail
    command -v aplay >/dev/null 2>&1 && exit 0
    apt-get install -y --no-install-recommends alsa-utils
probes:
- description: "alsa to be installed"
  script: |
    #!/bin/bash
    set -eux -o pipefail
    if ! timeout 30s bash -c "until command -v aplay >/dev/null 2>&1; do sleep 3; done"; then
      echo >&2 "alsa is not installed yet"
      exit 1
    fi
  hint: See "/var/log/cloud-init-output.log" in the guest
message: |
  To get a list of all available audio devices:
  $ sudo aplay -L
  To test the audio device, use something like:
  $ sudo speaker-test -c2 -twav
