devos/lib/pkgs-lib/tests/default.nix
Pacman99 e98e595704 pass builderArgs to config and extract builds
have mkHomeConfiguration create its own custom build within the function
create a externalModule for customBuilds so its easy to add more
2021-04-30 10:52:35 -07:00

56 lines
1.5 KiB
Nix

{ lib, deploy }:
let
mkChecks = { pkgs, hosts, nodes, homes ? { } }:
let
deployHosts = lib.filterAttrs
(n: _: hosts.${n}.config.nixpkgs.system == pkgs.system)
nodes;
deployChecks = deploy.lib.${pkgs.system}.deployChecks { nodes = deployHosts; };
tests =
lib.optionalAttrs (deployHosts != { })
{
profilesTest = profilesTest {
inherit pkgs;
host = hosts.${(builtins.head (builtins.attrNames deployHosts))};
};
} // lib.mapAttrs (n: v: v.activationPackage) homes;
in
lib.recursiveUpdate tests deployChecks;
mkTest = { pkgs, host }:
let
nixosTesting =
(import "${toString pkgs.path}/nixos/lib/testing-python.nix" {
inherit (pkgs) system;
inherit (host.config.lib.builderArgs) specialArgs;
inherit pkgs;
extraConfigurations = host._module.args.modules;
});
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;
profilesTest = args@{ host, ... }: mkTest args {
name = "profiles";
machine = { suites, ... }: {
imports = suites.allProfiles;
};
testScript = ''
${host.config.networking.hostName}.systemctl("is-system-running --wait")
'';
};
in
{ inherit mkTest profilesTest mkChecks; }