microvm-nix/microvm.nix
{ "createdAt": "2021-06-24T00:35:04Z", "defaultBranch": "main", "description": "NixOS MicroVMs", "fullName": "microvm-nix/microvm.nix", "homepage": "https://microvm-nix.github.io/microvm.nix/", "language": "Nix", "name": "microvm.nix", "pushedAt": "2026-01-03T03:59:14Z", "stargazersCount": 2075, "topics": [ "cloud-hypervisor", "crosvm", "firecracker", "flake", "flakes", "kvmtool", "microvm", "microvms", "nix", "nix-flake", "nixos", "qemu", "virtualization" ], "updatedAt": "2026-01-08T00:54:09Z", "url": "https://github.com/microvm-nix/microvm.nix"}MicroVM.nix
Section titled “MicroVM.nix”Handbook: HTML Markdown • Matrix chat • Changelog
A Nix Flake to build NixOS and run it on one of several Type-2
Hypervisors on NixOS/Linux or macOS. The project is intended to provide a more
isolated alternative to nixos-container. You can either build and
run MicroVMs like Nix packages, or alternatively install them as
systemd services declaratively in your host’s Nix Flake or
imperatively with the provided microvm command.
At a glance
Section titled “At a glance”- MicroVMs are Virtual Machines but use special device interfaces (virtio) for high performance.
- This project runs them on NixOS/Linux hosts and macOS (via vfkit).
- You can choose from eight hypervisors for each MicroVM.
- MicroVMs have a fixed RAM allocation (default: 512 MB) but can be
shrunk using
microvm-balloon - MicroVMs have a read-only root disk with either a prepopulated
/nix/storeor by mounting the host’s along with an optional writable overlay. This filesystem can be built as either squashfs (smaller) or erofs (faster). - You define your MicroVMs in a Nix Flake’s
nixosConfigurationssection, reusing thenixosModulesthat are exported by this Flake. - MicroVMs can access stateful filesystems either on a image volume as a block device, or alternatively as a shared directory hierarchy through 9p or virtiofs.
- Zero, one, or more virtual tap ethernet network interfaces can be
attached to a MicroVM.
qemu,kvmtool, andvfkitalso support user networking which requires no additional setup on the host.
Hypervisors
Section titled “Hypervisors”| Hypervisor | Language | Restrictions |
|---|---|---|
| qemu | C | |
| cloud-hypervisor | Rust | no 9p shares |
| firecracker | Rust | no 9p/virtiofs shares |
| crosvm | Rust | 9p shares broken |
| kvmtool | C | no virtiofs shares, no control socket |
| stratovirt | Rust | no 9p/virtiofs shares, no control socket |
| alioth | Rust | no virtiofs shares, no control socket |
| vfkit | Go | macOS only, no 9p shares, no tap/bridge networking |
Installation
Section titled “Installation”nix registry add microvm github:microvm-nix/microvm.nix(If you do not want to inflict this change on your system, just
replace microvm with github:microvm-nix/microvm.nix in the following
examples.)
Start writing your own NixOS MicroVM definitions
Section titled “Start writing your own NixOS MicroVM definitions”nix flake init -t microvm$EDITOR flake.nixnix run .#my-microvmExamples
Section titled “Examples”Run MicroVMs on your local machine
Section titled “Run MicroVMs on your local machine”nix run microvm#qemu-examplenix run microvm#firecracker-examplenix run microvm#cloud-hypervisor-examplenix run microvm#crosvm-examplenix run microvm#kvmtool-examplenix run microvm#stratovirt-example
# On macOS only:nix run microvm#vfkit-exampleRun a MicroVM example with nested MicroVMs on 5 different Hypervisors
Section titled “Run a MicroVM example with nested MicroVMs on 5 different Hypervisors”nix run microvm#vmCheck networkctl status virbr0 for the DHCP leases of the nested
MicroVMs. They listen for ssh with an empty root password.
Experimental: run graphical applications with graphics support
Section titled “Experimental: run graphical applications with graphics support”On Linux with cloud-hypervisor and Wayland forwarding:
nix run microvm#graphics neverballOn macOS with vfkit, enable graphics with microvm.graphics.enable = true.
Commercial support
Section titled “Commercial support”Accelerate your operations and secure your infrastructure with support from a team of virtualization experts. Contact Cyberus Technology: https://www.cyberus-technology.de/contact
Looking for help or customization?
Get in touch with Numtide to get a quote. We make it easy for companies to work with Open Source projects: https://numtide.com/contact