simplify deployment

This commit is contained in:
Kiara Grouwstra 2025-08-24 22:58:17 +02:00
parent 199bcca285
commit c900b7a9c5
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU

View file

@ -77,23 +77,18 @@ in
import ${pathToRoot}/deployment/nixos.nix { inherit configuration; } import ${pathToRoot}/deployment/nixos.nix { inherit configuration; }
' '
) )
# instantiate the config in /nix/store
"''${command[@]}" -A out_path
# get the other info
json="$("''${command[@]}" --eval --strict --json)"
# DEPLOY # DEPLOY
declare drv_path
# set our variables using the json object
eval "export $(echo $json | jq -r 'to_entries | map("\(.key)=\(.value)") | @sh')"
host="root@${nodeName}" host="root@${nodeName}"
sshOpts=( sshOpts=(
-o StrictHostKeyChecking=no -o StrictHostKeyChecking=no
-o "ConnectTimeout=1" -o "ConnectTimeout=1"
-o "ServerAliveInterval=1" -o "ServerAliveInterval=1"
) )
# instantiate the config in /nix/store
"''${command[@]}" -A out_path
# get the realized derivation to deploy # get the realized derivation to deploy
outPath=$(nix-store --realize "$drv_path") outPath=$(nix-store --realize "$("''${command[@]}" --eval --strict --json | jq -r '.drv_path')")
# deploy the config by nix-copy-closure # deploy the config by nix-copy-closure
NIX_SSHOPTS="''${sshOpts[*]}" nix-copy-closure --to "$host" "$outPath" --gzip --use-substitutes NIX_SSHOPTS="''${sshOpts[*]}" nix-copy-closure --to "$host" "$outPath" --gzip --use-substitutes
# switch the remote host to the config # switch the remote host to the config