Setting up NixOS Integration Tests¶
To run NixOS integration tests, you basically just need Nix and, for the best experience, KVM support.
-
Linux
The test driver can run virtual machines (qemu) and containers (systemd-nspawn). For good VM performance, run a bare-metal instance of Linux.
-
macOS
The test driver also runs on macOS. Only VMs are supported, not containers.
-
Nix
Use the multi-user installation for best experience.
-
KVM
Hardware-accelerated virtualisation makes VM tests fast.
Installation and setup check¶
Nix¶
The tests are all built and run with Nix. To install Nix, run the following command (see also Nix installer page):
Test your Nix installation like this:
If this works, you are ready to go: Continue writing your first minimal NixOS test here
Linux KVM¶
The important bit is that KVM is enabled, which enables hardware-accelerated virtualization. The tests also run without KVM but will be very slow in that case.
Check your KVM configuration:
- Running
lsmodshould show that thekvmmodules (with hardware platform specifickvm_*variants) are loaded: - Check that you and the Nix build users have write-access to
/dev/kvm: In this configuration, anyone has write-access to/dev/kvm, which is the simplest configuration method.
macOS setup¶
NixOS integration tests can run on macOS (Apple Silicon) by using a Linux builder or the apple-virt virtualization framework.
For more details, see the Nixcademy NixOS test driver guide for macOS.