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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-10-25 13:44:37 +02:00
|
|
|
rawTestDerivation = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
description = mdDoc ''
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
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 = {
|
2023-10-25 13:44:37 +02:00
|
|
|
rawTestDerivation = hostPkgs.stdenv.mkDerivation {
|
|
|
|
name = "vm-test-run-${config.name}";
|
2022-06-06 13:29:04 +02:00
|
|
|
|
2023-10-25 13:44:37 +02:00
|
|
|
requiredSystemFeatures = [ "kvm" "nixos-test" ];
|
2022-06-06 13:29:04 +02:00
|
|
|
|
2023-10-25 13:44:37 +02:00
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out
|
2022-06-06 13:29:04 +02:00
|
|
|
|
2023-10-25 13:44:37 +02:00
|
|
|
# effectively mute the XMLLogger
|
|
|
|
export LOGFILE=/dev/null
|
2022-06-06 13:29:04 +02:00
|
|
|
|
2023-10-25 13:44:37 +02:00
|
|
|
${config.driver}/bin/nixos-test-driver -o $out
|
|
|
|
'';
|
2022-06-06 13:29:04 +02:00
|
|
|
|
2023-10-25 13:44:37 +02:00
|
|
|
passthru = config.passthru;
|
2022-06-06 13:29:04 +02:00
|
|
|
|
2023-10-25 13:44:37 +02:00
|
|
|
meta = config.meta;
|
|
|
|
};
|
|
|
|
test = lib.lazyDerivation { # lazyDerivation improves performance when only passthru items and/or meta are used.
|
|
|
|
derivation = config.rawTestDerivation;
|
2022-06-25 12:47:50 +02:00
|
|
|
inherit (config) passthru meta;
|
2022-06-06 13:29:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
# useful for inspection (debugging / exploration)
|
|
|
|
passthru.config = config;
|
|
|
|
};
|
|
|
|
}
|