1 testModuleArgs@{ config, lib, hostPkgs, nodes, moduleType, ... }:
3 inherit (lib) mkOption types;
4 inherit (types) either str functionTo;
8 testScript = mkOption {
9 type = either str (functionTo str);
11 A series of python declarations and statements that you write to perform
15 testScriptString = mkOption {
21 includeTestScriptReferences = mkOption {
26 withoutTestScriptReferences = mkOption {
29 A parallel universe where the testScript is invalid and has no references.
36 withoutTestScriptReferences.includeTestScriptReferences = false;
37 withoutTestScriptReferences.testScript = lib.mkForce "testscript omitted";
40 if lib.isFunction config.testScript
47 if v.virtualisation.useNixStoreImage
49 # prevent infinite recursion when testScript would
50 # reference v's toplevel
51 config.withoutTestScriptReferences.nodesCompat.${k}
53 # reuse memoized config
58 else config.testScript;
60 defaults = { config, name, ... }: {
61 # Make sure all derivations referenced by the test
62 # script are available on the nodes. When the store is
63 # accessed through 9p, this isn't important, since
64 # everything in the store is available to the guest,
65 # but when building a root image it is, as all paths
66 # that should be available to the guest has to be
67 # copied to the image.
68 virtualisation.additionalPaths =
70 # A testScript may evaluate nodes, which has caused
71 # infinite recursions. The demand cycle involves:
76 # hasContext testScript' -->
77 # testScript (ad infinitum)
78 # If we don't need to build an image, we can break this
79 # cycle by short-circuiting when useNixStoreImage is false.
80 (config.virtualisation.useNixStoreImage && builtins.hasContext testModuleArgs.config.testScriptString && testModuleArgs.config.includeTestScriptReferences)
81 (hostPkgs.writeStringReferencesToFile testModuleArgs.config.testScriptString);