tests: refactor
This commit is contained in:
parent
8a6bd41baa
commit
d7a0cbefe5
12 changed files with 184 additions and 127 deletions
|
|
@ -3,23 +3,35 @@
|
|||
qpkgs ? let
|
||||
src = fetchTree (builtins.parseFlakeRef "github:Qyriad/nur-packages");
|
||||
in import src { inherit pkgs; },
|
||||
callPackage ? qpkgs.callPackage,
|
||||
lib ? qpkgs.lib,
|
||||
dynix ? qpkgs.callPackage ../package.nix { },
|
||||
}: let
|
||||
|
||||
mkDynixConfigurationDotNix = callPackage ./mk-test-configuration-dot-nix.nix { };
|
||||
|
||||
runDynixTest = testModule: pkgs.testers.runNixOSTest {
|
||||
imports = [ testModule ];
|
||||
|
||||
# NOTE: these are arguments to each *test module*.
|
||||
# Not the NixOS modules of the test's nodes.
|
||||
_module.args = { inherit mkDynixConfigurationDotNix; };
|
||||
|
||||
# Why is this argument called "extraBaseModule**s**" but take a single module argument...
|
||||
# Also note this is an extra base module for each node of the test,
|
||||
# not an extra test module.
|
||||
extraBaseModules = { name, config, options, modulesPath, ... }: {
|
||||
/**
|
||||
* Everything in this module will disappear once nixos-rebuild switch happens.
|
||||
* So each test will need to use `mkDynixConfigurationDotNix` to get
|
||||
* ./dynix-vm-configuration included in the in-VM configuration.
|
||||
*/
|
||||
|
||||
imports = (import "${modulesPath}/module-list.nix") ++ [
|
||||
./module-allow-rebuild-in-vm.nix
|
||||
"${modulesPath}/testing/test-instrumentation.nix"
|
||||
./dynix-vm-configuration.nix
|
||||
(toString dynix)
|
||||
];
|
||||
environment.systemPackages = [ dynix ];
|
||||
|
||||
systemd.services."install-dynix" = {
|
||||
enable = true;
|
||||
|
|
@ -27,9 +39,18 @@
|
|||
serviceConfig.RemainAfterExit = true;
|
||||
path = [ config.system.path ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig.requisteOf = [ "multi-user.target" ];
|
||||
after = [ "default.target" ];
|
||||
script = ''
|
||||
nix profile install -vv "$(realpath /run/current-system/sw/share/nixos/modules/dynix/)"
|
||||
nix profile install -vv "${dynix.modules}"
|
||||
|
||||
mkdir -vp /etc/nixos
|
||||
nixos-generate-config
|
||||
cp -rv --dereference /run/current-system/sw/share/nixos/*.nix /etc/nixos/
|
||||
if ! [[ -e /etc/nixos/dynix-vm-configuration.nix ]]; then
|
||||
echo "FAILURE"
|
||||
echo "FAILURE" >&2
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue