Files
nixpkgs/nixos/doc/manual/development/running-nixos-tests.section.md
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

1.7 KiB

Running Tests

You can run tests using nix-build. For example, to run the test login.nix, you do:

$ cd /my/git/clone/of/nixpkgs
$ nix-build -A nixosTests.login

After building/downloading all required dependencies, this will perform a build that starts a QEMU/KVM virtual machine containing a NixOS system. The virtual machine mounts the Nix store of the host; this makes VM creation very fast, as no disk image needs to be created. Afterwards, you can view a log of the test:

$ nix-store --read-log result

System Requirements

NixOS tests require virtualization support. This means that the machine must have kvm in its system features list, or apple-virt in case of macOS. These features are autodetected locally, but apple-virt is only autodetected since Nix 2.19.0.

Features of remote builders must additionally be configured manually on the client, e.g. on NixOS with nix.buildMachines.*.supportedFeatures or through general Nix configuration.

If you run the tests on a macOS machine, you also need a "remote" builder for Linux; possibly a VM. nix-darwin users may enable nix.linux-builder.enable to launch such a VM.