fix(packages/rebuild): fix remote host syntax

This commit is contained in:
Mohammad Rafiq 2025-06-02 21:28:36 +08:00
parent eb75c57653
commit 3c19c2a1c8
No known key found for this signature in database

View file

@ -25,7 +25,7 @@ pkgs.writeShellScriptBin "rebuild" # sh
git add . git add .
if [ ''${#REMOTE_HOSTS[@]} -gt 0 ]; then if [ ''${#REMOTE_HOSTS[@]} -gt 0 ]; then
for host in "$REMOTE_HOSTS[@]"; do for host in "$REMOTE_HOSTS"; do
echo "Rebuilding $host..." echo "Rebuilding $host..."
nixos-rebuild switch --flake .#"$host" --target-host "$host" --use-remote-sudo || { nixos-rebuild switch --flake .#"$host" --target-host "$host" --use-remote-sudo || {
echo "Error: nixos-rebuild switch failed for $host. Check the output." echo "Error: nixos-rebuild switch failed for $host. Check the output."
@ -37,26 +37,27 @@ pkgs.writeShellScriptBin "rebuild" # sh
CURRENT_GENERATION=$(readlink /nix/var/nix/profiles/system | cut -d- -f2) CURRENT_GENERATION=$(readlink /nix/var/nix/profiles/system | cut -d- -f2)
if "$TEST_SHELL"; then
nh os test . || { nh os test . || {
echo "Error: nixos-rebuild switch failed. Check the output for details." echo "Error: nixos-rebuild switch failed. Check the output for details."
exit 1 exit 1
} }
git diff HEAD --color=always --stat --patch git diff HEAD --color=always --stat --patch
if "$TEST_SHELL"; then
(export PS1="Test shell> " (export PS1="Test shell> "
exec ${pkgs.bash}/bin/bash) || { exec ${pkgs.bash}/bin/bash) || {
${pkgs.cowsay}/bin/cowsay "You aborted." ${pkgs.cowsay}/bin/cowsay "You aborted."
exit 1 exit 1
} }
fi
export NIXOS_LABEL="$(date +%d%m%y\ %H:%M:%S)"
nh os boot . || { nh os boot . || {
echo "Error: nixos-rebuild switch failed. Check the output for details." echo "Error: nixos-rebuild switch failed. Check the output for details."
exit 1 exit 1
} }
else
git diff HEAD --color=always --stat --patch
nh os switch . || {
exit 1
}
fi
NEW_GENERATION=$(readlink /nix/var/nix/profiles/system | cut -d- -f2) NEW_GENERATION=$(readlink /nix/var/nix/profiles/system | cut -d- -f2)
echo "New generation is $NEW_GENERATION. Current is $CURRENT_GENERATION." echo "New generation is $NEW_GENERATION. Current is $CURRENT_GENERATION."