mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00

Right now it wrongly seems as if you can set `sshBackdoor.enable = true;` for each test and not only for debugging purposes. This is wrong however since you'd need to pass /dev/vhost-vsock into the sandbox for this (which is also a prerequisite for #392117). To make that clear, two things were changed: * add a warning to the manual to communicate this. * exit both interactive and non-interactive driver early if /dev/vhost-vsock is missing and the ssh backdoor is enabled. If that's the case, we pass a CLI flag to the driver already in the interactive case. This change also sets the flag for the non-interactive case. That way we also get a better error if somebody tries to enable this on a system that doesn't support that.
79 lines
2.3 KiB
Nix
79 lines
2.3 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.
|
|
'';
|
|
};
|
|
|
|
rawTestDerivation = mkOption {
|
|
type = types.package;
|
|
description = ''
|
|
Unfiltered version of `test`, for troubleshooting the test framework and `testBuildFailure` in the test framework's test suite.
|
|
This is not intended for general use. Use `test` instead.
|
|
'';
|
|
internal = true;
|
|
};
|
|
|
|
test = mkOption {
|
|
type = types.package;
|
|
# TODO: can the interactive driver be configured to access the network?
|
|
description = ''
|
|
Derivation that runs the test as its "build" process.
|
|
|
|
This implies that NixOS tests run isolated from the network, making them
|
|
more dependable.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = {
|
|
rawTestDerivation =
|
|
assert lib.assertMsg (!config.sshBackdoor.enable)
|
|
"The SSH backdoor is currently not supported for non-interactive testing! Please make sure to only set `interactive.sshBackdoor.enable = true;`!";
|
|
hostPkgs.stdenv.mkDerivation {
|
|
name = "vm-test-run-${config.name}";
|
|
|
|
requiredSystemFeatures =
|
|
[ "nixos-test" ]
|
|
++ lib.optionals hostPkgs.stdenv.hostPlatform.isLinux [ "kvm" ]
|
|
++ lib.optionals hostPkgs.stdenv.hostPlatform.isDarwin [ "apple-virt" ];
|
|
|
|
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;
|
|
};
|
|
test = lib.lazyDerivation {
|
|
# lazyDerivation improves performance when only passthru items and/or meta are used.
|
|
derivation = config.rawTestDerivation;
|
|
inherit (config) passthru meta;
|
|
};
|
|
|
|
# useful for inspection (debugging / exploration)
|
|
passthru.config = config;
|
|
};
|
|
}
|