Skip to content

feat: add Linux support for Lima VMs#659

Merged
retlehs merged 3 commits intomasterfrom
linux-support
Apr 1, 2026
Merged

feat: add Linux support for Lima VMs#659
retlehs merged 3 commits intomasterfrom
linux-support

Conversation

@retlehs
Copy link
Copy Markdown
Member

@retlehs retlehs commented Mar 31, 2026

Summary

Adds Linux support for trellis vm commands using Lima with QEMU.

This keeps the existing macOS vz flow intact, adds Linux-specific Lima/QEMU config, and uses a host-reachable TAP network on Linux so Trellis local domains work without port suffixes.

Note

The main limitation that this only works with a single VM running at a time

What changed

  • enable Lima as the auto VM manager on Linux
  • add Linux qemu instance config alongside the existing macOS vz config
  • use 9p mounts on Linux with mapped-xattr so provisioning can chgrp mounted paths
  • keep stricter Lima requirement checks, but allow Linux distro packages that report a git-hash version string
  • add Linux TAP host networking setup during vm start
  • generate a per-project QEMU wrapper so Lima can launch QEMU with an extra TAP NIC
  • configure the guest-side TAP interface during provisioning
  • resolve Linux host mappings to the TAP IP so Trellis domains are reachable directly
  • update tests for the Linux config and startup path

Why

The earlier Linux Lima work in #648 proved that QEMU-based Linux VMs can boot and provision, but Lima's default Linux networking is not host-reachable in the way Trellis expects for local domains.

This PR adopts the TAP-networking direction from #633 so local sites work with normal Trellis hostnames instead of forwarded high ports.

Testing

Tested locally on Linux with a distro-packaged Lima build reporting:

limactl version b2acc1f

Verified locally:

  • trellis vm start
  • initial provisioning succeeds
  • local domain access works through /etc/hosts
  • trellis open
  • TAP interface ownership/setup works for the invoking user
  • go test ./pkg/lima
  • go build ./...

Some broader repo integration tests still depend on TEST_BINARY or local socket listeners and were not used as the Linux validation path here.

Attribution

This work builds directly on prior Linux support work from:

Close #599

@retlehs retlehs force-pushed the linux-support branch 2 times, most recently from 3d93281 to 06b2bae Compare March 31, 2026 19:42
Comment thread cmd/open.go
Co-authored-by: David Stone <david@nnucomputerwhiz.com>
Co-authored-by: Md Kabir Uddin <bd.kabiruddin@gmail.com>
swalkinshaw and others added 2 commits March 31, 2026 17:58
…ough logic

Set PATH via Cmd.Env on the limactl start command instead of mutating the
process-wide environment with os.Setenv. This prevents an infinite exec
loop where LookPath would resolve to the wrapper itself on subsequent calls.

Also replaces the fragile help/version denylist in the wrapper script with
a simpler check: only inject TAP args when -netdev is present (indicating
a real VM launch vs a Lima feature probe).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
HostAccessIP was a no-op wrapper around IP(). Since the TAP networking
constants are hardcoded to a single set of values (one VM at a time on
Linux), there's no need for the indirection yet. Added a comment on the
constants noting this single-instance constraint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@swalkinshaw swalkinshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed two small fixes/improvements good now 👍 We can iterate on this

I'd just note in the PR description the main limitation that this only works with a single VM running at a time.

@retlehs retlehs merged commit 0e75ae7 into master Apr 1, 2026
8 checks passed
@retlehs retlehs deleted the linux-support branch April 1, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Did you just drop Linux support?

2 participants