Skip to content

Commit

Permalink
nixos/testing-python: Copy test script derivations to nodes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
talyz authored and yu-re-ka committed Oct 28, 2021
1 parent aa22fa9 commit 329a446
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions nixos/lib/testing-python.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 329a446

Please sign in to comment.