What is the correct way to run the tests in nixpkgs/pkgs/build-support/vm/test.nix?

Nixpkgs’s pkgs/README.md file says:

Package tests

To run the main types of tests locally:

  • Run package-internal tests with nix-build --attr pkgs.PACKAGE.passthru.tests
  • Run NixOS tests with nix-build --attr nixosTests.NAME, where NAME is the name of the test listed in nixos/tests/all-tests.nix
  • Run global package tests with nix-build --attr tests.PACKAGE, where PACKAGE is the name of the test listed in pkgs/test/default.nix
  • See lib/tests/NAME.nix for instructions on running specific library tests

pkgs/build-support/vm/test.nix looks like it contains tests, but it doesn’t really fit into any of those categories. What is the correct way to run the tests that are defined in pkgs/build-support/vm/test.nix?

You just have to reference the file directly, as it’s not referenced anywhere in nixpkgs.

nix-build pkgs/build-support/vm/test.nix -A <attrname>
1 Like