forked from Fediversity/Fediversity
72 lines
1.6 KiB
Nix
72 lines
1.6 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
inherit (import ./constants.nix) pathToRoot pathFromRoot;
|
|
inherit (pkgs) system;
|
|
deployment-config = {
|
|
inherit pathToRoot pathFromRoot;
|
|
nodeName = "ssh";
|
|
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
|
|
})."ssh-deployment".ssh-host.run;
|
|
in
|
|
{
|
|
_class = "nixosTest";
|
|
imports = [
|
|
../common/data-model-options.nix
|
|
];
|
|
|
|
name = "deployment-model";
|
|
sourceFileset = lib.fileset.unions [
|
|
../../data-model.nix
|
|
../../function.nix
|
|
../../nixos.nix
|
|
../../run/ssh-single-host/run.sh
|
|
../../../npins/default.nix
|
|
../../../npins/sources.json
|
|
../common/data-model.nix
|
|
../common/data-model-options.nix
|
|
./constants.nix
|
|
];
|
|
|
|
nodes.deployer =
|
|
{ pkgs, ... }:
|
|
{
|
|
environment.systemPackages = with pkgs; [
|
|
jq
|
|
deploy
|
|
];
|
|
|
|
system.extraDependenciesFromModule =
|
|
{ pkgs, ... }:
|
|
{
|
|
environment.systemPackages = with pkgs; [
|
|
hello
|
|
];
|
|
};
|
|
};
|
|
|
|
extraTestScript = ''
|
|
with subtest("Check the status before deployment"):
|
|
ssh.fail("hello 1>&2")
|
|
|
|
with subtest("Run the deployment"):
|
|
deployer.succeed("""
|
|
${lib.getExe deploy}
|
|
""")
|
|
ssh.wait_for_unit("multi-user.target")
|
|
ssh.succeed("su - operator -c hello 1>&2")
|
|
'';
|
|
}
|