2022-06-06 13:29:04 +02:00
|
|
|
{ config, hostPkgs, lib, ... }:
|
|
|
|
let
|
2022-06-27 20:06:30 +02:00
|
|
|
inherit (lib) types mkOption mdDoc;
|
2022-06-06 13:29:04 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
passthru = mkOption {
|
|
|
|
type = types.lazyAttrsOf types.raw;
|
2022-06-27 20:06:30 +02:00
|
|
|
description = mdDoc ''
|
2022-06-06 13:29:04 +02:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-06-25 12:47:50 +02:00
|
|
|
test = mkOption {
|
2022-06-06 13:29:04 +02:00
|
|
|
type = types.package;
|
2022-06-27 20:06:30 +02:00
|
|
|
# TODO: can the interactive driver be configured to access the network?
|
|
|
|
description = mdDoc ''
|
2022-06-25 12:47:50 +02:00
|
|
|
Derivation that runs the test as its "build" process.
|
2022-06-27 20:06:30 +02:00
|
|
|
|
|
|
|
This implies that NixOS tests run isolated from the network, making them
|
|
|
|
more dependable.
|
2022-06-06 13:29:04 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2022-06-25 12:47:50 +02:00
|
|
|
test = lib.lazyDerivation { # lazyDerivation improves performance when only passthru items and/or meta are used.
|
|
|
|
derivation = hostPkgs.stdenv.mkDerivation {
|
|
|
|
name = "vm-test-run-${config.name}";
|
2022-06-06 13:29:04 +02:00
|
|
|
|
2022-06-25 12:47:50 +02:00
|
|
|
requiredSystemFeatures = [ "kvm" "nixos-test" ];
|
2022-06-06 13:29:04 +02:00
|
|
|
|
2022-06-25 12:47:50 +02:00
|
|
|
buildCommand = ''
|
2022-06-06 13:29:04 +02:00
|
|
|
mkdir -p $out
|
|
|
|
|
|
|
|
# effectively mute the XMLLogger
|
|
|
|
export LOGFILE=/dev/null
|
|
|
|
|
|
|
|
${config.driver}/bin/nixos-test-driver -o $out
|
|
|
|
'';
|
|
|
|
|
2022-06-25 12:47:50 +02:00
|
|
|
passthru = config.passthru;
|
2022-06-06 13:29:04 +02:00
|
|
|
|
2022-06-25 12:47:50 +02:00
|
|
|
meta = config.meta;
|
|
|
|
};
|
|
|
|
inherit (config) passthru meta;
|
2022-06-06 13:29:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
# useful for inspection (debugging / exploration)
|
|
|
|
passthru.config = config;
|
|
|
|
};
|
|
|
|
}
|