From 329a4461a7a1898b3aad13968a232a054422c4fb Mon Sep 17 00:00:00 2001 From: talyz Date: Wed, 6 Oct 2021 18:47:56 +0200 Subject: nixos/testing-python: Copy test script derivations to nodes Make sure the all derivations referenced by the test script are available on the nodes. Accessing these derivations works just fine without this change when using 9p to mount the host's store, but when an image is built (virtualisation.buildRootImage), the dependencies need to be copied to the image. We don't want to copy the script itself, though, since that would trigger unnecessary image rebuilds. --- nixos/lib/testing-python.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'nixos/lib/testing-python.nix') diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index dbba9e4c44526..b1e9bed4a5c11 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -209,11 +209,30 @@ rec { let nodes = qemu_pkg: let + testScript' = + # Call the test script with the computed nodes. + if lib.isFunction testScript + then testScript { nodes = nodes qemu_pkg; } + else testScript; + build-vms = import ./build-vms.nix { inherit system lib pkgs minimal specialArgs; extraConfigurations = extraConfigurations ++ [( { virtualisation.qemu.package = qemu_pkg; + + # Make sure all derivations referenced by the test + # script are available on the nodes. When the store is + # accessed through 9p, this isn't important, since + # everything in the store is available to the guest, + # but when building a root image it is, as all paths + # that should be available to the guest has to be + # copied to the image. + virtualisation.additionalPaths = + lib.optional + (builtins.hasContext testScript') + (pkgs.writeStringReferencesToFile testScript'); + # Ensure we do not use aliases. Ideally this is only set # when the test framework is used by Nixpkgs NixOS tests. nixpkgs.config.allowAliases = false; -- cgit 1.4.1