2021-04-26 01:36:48 +02:00
|
|
|
{ lib, deploy }:
|
2021-03-14 08:10:51 +01:00
|
|
|
let
|
2021-04-26 01:36:48 +02:00
|
|
|
mkChecks = { pkgs, hosts, nodes, homes ? { } }:
|
2021-04-10 19:59:10 +02:00
|
|
|
let
|
|
|
|
deployHosts = lib.filterAttrs
|
2021-04-26 01:36:48 +02:00
|
|
|
(n: _: hosts.${n}.config.nixpkgs.system == pkgs.system)
|
2021-04-10 19:59:10 +02:00
|
|
|
nodes;
|
2021-04-26 01:36:48 +02:00
|
|
|
deployChecks = deploy.lib.${pkgs.system}.deployChecks { nodes = deployHosts; };
|
2021-04-10 19:59:10 +02:00
|
|
|
tests =
|
2021-04-24 03:13:03 +02:00
|
|
|
lib.optionalAttrs (deployHosts != { })
|
|
|
|
{
|
2021-04-26 01:36:48 +02:00
|
|
|
profilesTest = profilesTest {
|
|
|
|
inherit pkgs;
|
|
|
|
host = hosts.${(builtins.head (builtins.attrNames deployHosts))};
|
|
|
|
};
|
2021-04-24 03:13:03 +02:00
|
|
|
} // lib.mapAttrs (n: v: v.activationPackage) homes;
|
2021-04-10 19:59:10 +02:00
|
|
|
|
|
|
|
in
|
|
|
|
lib.recursiveUpdate tests deployChecks;
|
2021-03-14 08:10:51 +01:00
|
|
|
|
2021-04-26 01:36:48 +02:00
|
|
|
mkTest = { pkgs, host }:
|
2021-03-14 08:10:51 +01:00
|
|
|
let
|
|
|
|
nixosTesting =
|
2021-04-26 01:36:48 +02:00
|
|
|
(import "${toString pkgs.path}/nixos/lib/testing-python.nix" {
|
|
|
|
inherit (pkgs) system;
|
2021-04-28 20:30:04 +02:00
|
|
|
inherit (host.config.lib.builderArgs) specialArgs;
|
2021-03-14 08:10:51 +01:00
|
|
|
inherit pkgs;
|
2021-04-28 20:30:04 +02:00
|
|
|
extraConfigurations = host._module.args.modules;
|
2021-03-14 08:10:51 +01:00
|
|
|
});
|
|
|
|
in
|
|
|
|
test:
|
|
|
|
let
|
|
|
|
loadedTest =
|
|
|
|
if builtins.typeOf test == "path"
|
|
|
|
then import test
|
|
|
|
else test;
|
|
|
|
calledTest =
|
|
|
|
if pkgs.lib.isFunction loadedTest
|
|
|
|
then pkgs.callPackage loadedTest { }
|
|
|
|
else loadedTest;
|
|
|
|
in
|
|
|
|
nixosTesting.makeTest calledTest;
|
2021-04-10 19:59:10 +02:00
|
|
|
|
2021-04-26 01:36:48 +02:00
|
|
|
profilesTest = args@{ host, ... }: mkTest args {
|
2021-03-15 03:14:51 +01:00
|
|
|
name = "profiles";
|
2021-03-14 08:10:51 +01:00
|
|
|
|
2021-03-15 03:14:51 +01:00
|
|
|
machine = { suites, ... }: {
|
2021-04-26 01:36:48 +02:00
|
|
|
imports = suites.allProfiles;
|
2021-03-14 08:10:51 +01:00
|
|
|
};
|
|
|
|
|
2021-03-15 03:14:51 +01:00
|
|
|
testScript = ''
|
2021-04-26 01:36:48 +02:00
|
|
|
${host.config.networking.hostName}.systemctl("is-system-running --wait")
|
2021-03-14 08:10:51 +01:00
|
|
|
'';
|
|
|
|
};
|
2021-04-10 19:59:10 +02:00
|
|
|
in
|
2021-04-18 02:30:55 +02:00
|
|
|
{ inherit mkTest profilesTest mkChecks; }
|