forked from Fediversity/Fediversity
66 lines
1.5 KiB
Nix
66 lines
1.5 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
inherit (import ./constants.nix) pathToRoot pathFromRoot;
|
|
inherit (pkgs) system;
|
|
deployment-config = {
|
|
inherit pathToRoot pathFromRoot;
|
|
nodeName = "target";
|
|
targetSystem = system;
|
|
sshOpts = [
|
|
"ConnectTimeout=1"
|
|
"ServerAliveInterval=1"
|
|
];
|
|
};
|
|
deploy =
|
|
(import ../common/data-model.nix {
|
|
inherit system;
|
|
config = deployment-config;
|
|
# opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call
|
|
})."tf-deployment".tf-host.run;
|
|
in
|
|
{
|
|
_class = "nixosTest";
|
|
imports = [
|
|
../common/data-model-options.nix
|
|
];
|
|
|
|
name = "deployment-model";
|
|
sourceFileset = lib.fileset.unions [
|
|
../../run/tf-single-host/run.sh
|
|
];
|
|
|
|
nodes.deployer =
|
|
{ pkgs, ... }:
|
|
{
|
|
environment.systemPackages = with pkgs; [
|
|
(pkgs.callPackage ../../run/tf-single-host/tf.nix { })
|
|
jq
|
|
deploy
|
|
];
|
|
|
|
# needed only when building from deployer
|
|
system.extraDependenciesFromModule =
|
|
{ pkgs, ... }:
|
|
{
|
|
environment.systemPackages = with pkgs; [
|
|
hello
|
|
];
|
|
};
|
|
};
|
|
|
|
extraTestScript = ''
|
|
with subtest("ssh: Check the status before deployment"):
|
|
target.fail("hello 1>&2")
|
|
|
|
with subtest("ssh: Run the deployment"):
|
|
deployer.succeed("""
|
|
${lib.getExe deploy}
|
|
""")
|
|
target.wait_for_unit("multi-user.target")
|
|
target.succeed("su - operator -c hello 1>&2")
|
|
'';
|
|
}
|