nixpkgs/nixos/lib/testing/run.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

77 lines
2.1 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 = 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;
};
}