forked from Fediversity/Fediversity
switch reusable script to package, facilitating inspection and reuse
This commit is contained in:
parent
6862fd17a1
commit
ee026c804d
2 changed files with 7 additions and 6 deletions
|
@ -15,12 +15,12 @@ let
|
||||||
"ServerAliveInterval=1"
|
"ServerAliveInterval=1"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
deployment =
|
deploy =
|
||||||
(import ../common/data-model.nix {
|
(import ../common/data-model.nix {
|
||||||
inherit system;
|
inherit system;
|
||||||
config = deployment-config;
|
config = deployment-config;
|
||||||
# opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call
|
# opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call
|
||||||
})."ssh-deployment".ssh-host;
|
})."ssh-deployment".ssh-host.run;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
_class = "nixosTest";
|
_class = "nixosTest";
|
||||||
|
@ -46,6 +46,7 @@ in
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
jq
|
jq
|
||||||
|
deploy
|
||||||
];
|
];
|
||||||
|
|
||||||
system.extraDependenciesFromModule =
|
system.extraDependenciesFromModule =
|
||||||
|
@ -63,7 +64,7 @@ in
|
||||||
|
|
||||||
with subtest("Run the deployment"):
|
with subtest("Run the deployment"):
|
||||||
deployer.succeed("""
|
deployer.succeed("""
|
||||||
${deployment.run}
|
${lib.getExe deploy}
|
||||||
""")
|
""")
|
||||||
ssh.wait_for_unit("multi-user.target")
|
ssh.wait_for_unit("multi-user.target")
|
||||||
ssh.succeed("su - operator -c hello 1>&2")
|
ssh.succeed("su - operator -c hello 1>&2")
|
||||||
|
|
|
@ -20,7 +20,7 @@ let
|
||||||
;
|
;
|
||||||
toBash =
|
toBash =
|
||||||
v:
|
v:
|
||||||
lib.replaceStrings [ "\"" ] [ "\\\\\"" ] (
|
lib.replaceStrings [ "\"" ] [ "\\\"" ] (
|
||||||
if lib.isPath v || builtins.isNull v then
|
if lib.isPath v || builtins.isNull v then
|
||||||
toString v
|
toString v
|
||||||
else if lib.isString v then
|
else if lib.isString v then
|
||||||
|
@ -112,7 +112,7 @@ let
|
||||||
type = types.path;
|
type = types.path;
|
||||||
};
|
};
|
||||||
run = mkOption {
|
run = mkOption {
|
||||||
type = types.str;
|
type = types.package;
|
||||||
# error: The option `ssh-deployment.ssh-host.run' is read-only, but it's set multiple times.
|
# error: The option `ssh-deployment.ssh-host.run' is read-only, but it's set multiple times.
|
||||||
# readOnly = true;
|
# readOnly = true;
|
||||||
default =
|
default =
|
||||||
|
@ -146,7 +146,7 @@ let
|
||||||
deployment_type = "ssh-host";
|
deployment_type = "ssh-host";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
''
|
pkgs.writeShellScriptBin "deploy-ssh.sh" ''
|
||||||
env ${
|
env ${
|
||||||
toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") environment)
|
toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") environment)
|
||||||
} bash ./deployment/run/ssh-single-host/run.sh
|
} bash ./deployment/run/ssh-single-host/run.sh
|
||||||
|
|
Loading…
Add table
Reference in a new issue