Lima: A simpler path to Linux VMs on macOS

Running Linux-specific software on macOS often means fighting with VMs or container layers. A recent experience with an nginx sandbox that relies on Linux namespaces via bubblewrap highlighted this gap. Lima, which stands for Linux on Mac, offers a more direct solution than traditional tools like Vagrant.

Getting started with Lima

Setup is intentionally minimal. After installing with nix-env -iA nixpkgs.lima or brew install lima, you start the default VM with limactl start default and then simply run lima to open a shell. That's the whole process.

The tool provides a sensible default configuration and automatically downloads an Ubuntu 22.04 image. By default, it mounts your entire home directory inside the VM as read-only. This seamless access to your existing files is a strong default choice, and you can find further configuration in ~/.lima/default/lima.yaml.

The design philosophy of maintaining one general-purpose Linux VM for all projects—rather than carefully isolated per-project setups—feels pragmatic for day-to-day work. Lima does support per-project VMs as well, but the single default instance covers most needs.

Limitations to keep in mind

Two issues emerged during hands-on use. First, mounting specific subdirectories (like ~/work/nginx-playground) as read-write while keeping the rest of the home directory read-only is not straightforward. Community guidance suggests this is possible by setting mountType: "virtiofs" and vmType: "vz" in the config, but the Lima version packaged in nix 23.05 may not support the vz VM type.

Second, networking has quirks. Although a tun device setup initially appeared to work, it proved unreliable. ICMP also behaves strangely; pinging a machine produces unexpected output, which appears to be a known issue with Lima's networking stack.

Why a VM instead of a container?

For workloads like the nginx playground, avoiding containers is a deliberate choice. The production environment runs on a VM, so developing in a similar setup reduces surprises. Additionally, using Linux namespaces inside a container adds a layer of complexity that isn't worth debugging. On macOS, containers require a Linux VM underneath anyway, so using the VM directly eliminates an unnecessary abstraction.

OrbStack as a comparable alternative

After encountering networking troubles, OrbStack emerged as a viable alternative. In testing, its network handling was notably better: ping behaves normally instead of producing odd output. Setup is equally straightforward via the GUI: download, create a VM, then run orb.

Both tools also deserve consideration beyond this narrow use case. Lima runs on Linux as well, and colima — built on top of Lima — is often recommended as a Docker alternative for running Linux containers on macOS.