feat(packages/rebuild): add multi host rebuild to rebuild script

This commit is contained in:
Mohammad Rafiq 2025-05-29 16:47:22 +08:00
parent 591c90db68
commit 8e12382f60
No known key found for this signature in database

View file

@ -1,14 +1,22 @@
{ pkgs, ... }: { pkgs, ... }:
pkgs.writeShellScriptBin "rebuild" # sh pkgs.writeShellScriptBin "rebuild" # sh
'' ''
CURRENT_GENERATION=$(readlink /nix/var/nix/profiles/system | cut -d- -f2)
if [ ! -f "flake.nix" ]; then if [ ! -f "flake.nix" ]; then
echo "Error: flake.nix not found in the current directory. Exiting." echo "Error: flake.nix not found in the current directory. Exiting."
exit 1 # Indicate an error exit 1 # Indicate an error
fi fi
git add . git add .
if [ $# -gt 0 ]; then
for arg in "$@"; do
nixos-rebuild switch --flake .#"$arg" --target-host "$arg" --use-remote-sudo
done
exit 0
fi
CURRENT_GENERATION=$(readlink /nix/var/nix/profiles/system | cut -d- -f2)
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