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