From d2e4b94d8af8e6a4b389a2ab6a824e4d628a51f5 Mon Sep 17 00:00:00 2001 From: Jacek Galowicz Date: Sat, 26 Oct 2024 17:38:15 +0200 Subject: [PATCH] nixos documentation: Suggest pkgs.testers.runNixOSTest `pkgs.testers.runNixOSTest` is the latest and best way to run NixOS Tests outside of nixpkgs as it also improves evaluation performance by injecting the host pkgs into all the guests. It seems no one uses it because it is not mentioned at the right places. --- .../manual/development/writing-nixos-tests.section.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nixos/doc/manual/development/writing-nixos-tests.section.md b/nixos/doc/manual/development/writing-nixos-tests.section.md index 3ce12f41c60f..bd588e2ba80b 100644 --- a/nixos/doc/manual/development/writing-nixos-tests.section.md +++ b/nixos/doc/manual/development/writing-nixos-tests.section.md @@ -71,20 +71,20 @@ nix-build -A nixosTests.hostname ### Testing outside the NixOS project {#sec-call-nixos-test-outside-nixos} -Outside the `nixpkgs` repository, you can instantiate the test by first importing the NixOS library, +Outside the `nixpkgs` repository, you can use the `runNixOSTest` function from +`pkgs.testers`: ```nix -let nixos-lib = import (nixpkgs + "/nixos/lib") { }; +let pkgs = import {}; in -nixos-lib.runTest { +pkgs.testers.runNixOSTest { imports = [ ./test.nix ]; - hostPkgs = pkgs; # the Nixpkgs package set used outside the VMs defaults.services.foo.package = mypkg; } ``` -`runTest` returns a derivation that runs the test. +`runNixOSTest` returns a derivation that runs the test. ## Configuring the nodes {#sec-nixos-test-nodes}