2021-04-02 05:10:24 +03:00
|
|
|
{ pkgs, system, inputs, nixpkgs, lib, ... }:
|
2021-03-14 10:10:51 +03:00
|
|
|
let
|
2021-04-10 20:59:10 +03:00
|
|
|
mkChecks = { hosts, nodes, homes ? { } }:
|
|
|
|
let
|
|
|
|
deployHosts = lib.filterAttrs
|
|
|
|
(n: _: hosts.${n}.config.nixpkgs.system == system)
|
|
|
|
nodes;
|
|
|
|
deployChecks = inputs.deploy.lib.${system}.deployChecks { nodes = deployHosts; };
|
|
|
|
tests =
|
2021-04-18 03:30:55 +03:00
|
|
|
lib.optionalAttrs (deployHosts != { }) {
|
2021-04-10 20:59:10 +03:00
|
|
|
profilesTest = profilesTest (hosts.${(builtins.head (builtins.attrNames deployHosts))});
|
2021-04-11 08:13:54 +03:00
|
|
|
} // lib.mapAttrs (n: v: v.activationPackage) homes;
|
2021-04-10 20:59:10 +03:00
|
|
|
|
|
|
|
in
|
|
|
|
lib.recursiveUpdate tests deployChecks;
|
2021-03-14 10:10:51 +03:00
|
|
|
|
2021-04-10 20:59:10 +03:00
|
|
|
mkTest = host:
|
2021-03-14 10:10:51 +03:00
|
|
|
let
|
|
|
|
nixosTesting =
|
2021-04-02 05:10:24 +03:00
|
|
|
(import "${nixpkgs}/nixos/lib/testing-python.nix" {
|
2021-04-10 20:59:10 +03:00
|
|
|
inherit system;
|
|
|
|
inherit (host.config.lib) specialArgs;
|
2021-03-14 10:10:51 +03:00
|
|
|
inherit pkgs;
|
|
|
|
extraConfigurations = [
|
2021-04-10 20:59:10 +03:00
|
|
|
host.config.lib.testModule
|
2021-03-14 10:10:51 +03: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 20:59:10 +03:00
|
|
|
|
|
|
|
profilesTest = host: mkTest host {
|
2021-03-15 05:14:51 +03:00
|
|
|
name = "profiles";
|
2021-03-14 10:10:51 +03:00
|
|
|
|
2021-03-15 05:14:51 +03:00
|
|
|
machine = { suites, ... }: {
|
|
|
|
imports = suites.allProfiles ++ suites.allUsers;
|
2021-03-14 10:10:51 +03:00
|
|
|
};
|
|
|
|
|
2021-03-15 05:14:51 +03:00
|
|
|
testScript = ''
|
|
|
|
machine.systemctl("is-system-running --wait")
|
2021-03-14 10:10:51 +03:00
|
|
|
'';
|
|
|
|
};
|
2021-04-10 20:59:10 +03:00
|
|
|
in
|
2021-04-18 03:30:55 +03:00
|
|
|
{ inherit mkTest profilesTest mkChecks; }
|