have tf test also use package

Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
This commit is contained in:
Kiara Grouwstra 2025-09-03 15:08:09 +02:00
parent 1addef3fc5
commit 8113ec70ce
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU
2 changed files with 6 additions and 5 deletions

View file

@ -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
})."tf-deployment".tf-host; })."tf-deployment".tf-host.run;
in in
{ {
_class = "nixosTest"; _class = "nixosTest";
@ -39,6 +39,7 @@ in
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
(pkgs.callPackage ../../run/tf-single-host/tf.nix { }) (pkgs.callPackage ../../run/tf-single-host/tf.nix { })
jq jq
deploy
]; ];
# needed only when building from deployer # needed only when building from deployer
@ -57,7 +58,7 @@ in
with subtest("ssh: Run the deployment"): with subtest("ssh: Run the deployment"):
deployer.succeed(""" deployer.succeed("""
${deployment.run} ${lib.getExe deploy}
""") """)
target.wait_for_unit("multi-user.target") target.wait_for_unit("multi-user.target")
target.succeed("su - operator -c hello 1>&2") target.succeed("su - operator -c hello 1>&2")

View file

@ -186,7 +186,7 @@ let
type = types.path; type = types.path;
}; };
run = mkOption { run = mkOption {
type = types.str; type = types.package;
# error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times. # error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times.
# readOnly = true; # readOnly = true;
default = default =
@ -221,7 +221,7 @@ let
}; };
tf-env = pkgs.callPackage ./run/tf-single-host/tf-env.nix { }; tf-env = pkgs.callPackage ./run/tf-single-host/tf-env.nix { };
in in
'' pkgs.writeShellScriptBin "deploy-ssh.sh" ''
env ${toString (lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") environment)} \ env ${toString (lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") environment)} \
tf_env=${tf-env} bash ./deployment/run/tf-single-host/run.sh tf_env=${tf-env} bash ./deployment/run/tf-single-host/run.sh
''; '';