b3de22483c
This is a decomposition of the testing-python.nix and build-vms.nix files into modules. By refactoring the glue, we accomplish the following: - NixOS tests can now use `imports` and other module system features. - Network-wide test setup can now be reusable; example: - A setup with all VMs configured to use a DNS server - Split long, slow tests into multiple tests that import a common module that has most of the setup. - Type checking for the test arguments - (TBD) "generated" options reference docs - Aspects that had to be wired through all the glue are now in their own files. - Chief example: interactive.nix. - Also: network.nix In rewriting this, I've generally stuck as close as possible to the existing code; copying pieces of logic and rewiring them, without changing the logic itself. I've made two exceptions to this rule - Introduction of `extraDriverArgs` instead of hardcoded interactivity logic. - Incorporation of https://github.com/NixOS/nixpkgs/pull/144110 in testScript.nix. I might revert the latter and split it into a new commit.
52 lines
1.2 KiB
Nix
52 lines
1.2 KiB
Nix
{ config, hostPkgs, lib, ... }:
|
|
let
|
|
inherit (lib) types mkOption;
|
|
in
|
|
{
|
|
options = {
|
|
passthru = mkOption {
|
|
type = types.lazyAttrsOf types.raw;
|
|
description = ''
|
|
Attributes to add to the returned derivations,
|
|
which are not necessarily part of the build.
|
|
|
|
This is a bit like doing `drv // { myAttr = true; }` (which would be lost by `overrideAttrs`).
|
|
It does not change the actual derivation, but adds the attribute nonetheless, so that
|
|
consumers of what would be `drv` have more information.
|
|
'';
|
|
};
|
|
|
|
run = mkOption {
|
|
type = types.package;
|
|
description = ''
|
|
Derivation that runs the test.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = {
|
|
run = hostPkgs.stdenv.mkDerivation {
|
|
name = "vm-test-run-${config.name}";
|
|
|
|
requiredSystemFeatures = [ "kvm" "nixos-test" ];
|
|
|
|
buildCommand =
|
|
''
|
|
mkdir -p $out
|
|
|
|
# effectively mute the XMLLogger
|
|
export LOGFILE=/dev/null
|
|
|
|
${config.driver}/bin/nixos-test-driver -o $out
|
|
'';
|
|
|
|
passthru = config.passthru;
|
|
|
|
meta = config.meta;
|
|
};
|
|
|
|
# useful for inspection (debugging / exploration)
|
|
passthru.config = config;
|
|
};
|
|
}
|