No description
Find a file
Sandro Jäckel 4fe0a520d9
Some checks failed
Dead code analysis / Deadnix (push) Has been cancelled
Documentation / build and deploy doc (push) Has been cancelled
prebuilt-25.05 / build (push) Has been cancelled
prebuilt-unstable / build (push) Has been cancelled
Typos / Spellcheck / Spellcheck (push) Has been cancelled
Add missing defaultText to fix doc build
2025-08-23 03:07:12 +02:00
.github deadnix: disable PRs 2025-07-22 15:20:21 +02:00
checks Incorporate PR review feedback 2025-07-23 11:24:00 +02:00
doc move from github.com/astro to github.com/microvm-nix 2025-07-17 21:51:33 +02:00
examples Use shorter attr style in some places 2025-07-22 00:33:44 +02:00
flake-template move from github.com/astro to github.com/microvm-nix 2025-07-17 21:51:33 +02:00
lib lib/volumes.nix: make independent of microvmConfig 2025-08-21 21:05:07 +02:00
nixos-modules Add missing defaultText to fix doc build 2025-08-23 03:07:12 +02:00
pkgs move from github.com/astro to github.com/microvm-nix 2025-07-17 21:51:33 +02:00
.editorconfig Bump line length to 150 2025-07-22 21:12:41 +02:00
.gitignore proof of concept: qemu 2021-06-23 20:54:42 +02:00
.typos.toml treewide: init typos + fix 2024-04-08 16:44:39 +02:00
CHANGELOG.md add configurable group option for virtiofsd socket 2025-07-18 10:40:11 +02:00
flake.lock flake.lock: Update (#399) 2025-08-13 14:44:05 +02:00
flake.nix flake.nix: enable example packages for darwin 2025-08-21 22:31:22 +02:00
LICENSE LICENSE: add 2021-07-30 23:17:41 +02:00
README.md move from github.com/astro to github.com/microvm-nix 2025-07-17 21:51:33 +02:00

MicroVM.nix

Handbook: HTML MarkdownMatrix chatChangelog

Demo GIF

A Nix Flake to build NixOS and run it on one of several Type-2 Hypervisors on NixOS/Linux. 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.

Project Presentation (video)

At a glance

  • MicroVMs are Virtual Machines but use special device interfaces (virtio) for high performance.
  • This project runs them on NixOS hosts.
  • You can choose one of five 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/store or 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 nixosConfigurations section, reusing the nixosModules that 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 and kvmtool also support user networking which requires no additional setup on the host.

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

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

nix flake init -t microvm
$EDITOR flake.nix
nix run .#my-microvm

Examples

Run MicroVMs on your local machine

nix run microvm#qemu-example
nix run microvm#firecracker-example
nix run microvm#cloud-hypervisor-example
nix run microvm#crosvm-example
nix run microvm#kvmtool-example
nix run microvm#stratovirt-example

Run a MicroVM example with nested MicroVMs on 5 different Hypervisors

nix run microvm#vm

Check networkctl status virbr0 for the DHCP leases of the nested MicroVMs. They listen for ssh with an empty root password.

Experimental: run graphical applications in cloud-hypervisor with Wayland forwarding

nix run microvm#graphics neverball

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