From 8b1551266b387a8ec507c9f8334d72f34c63b6f8 Mon Sep 17 00:00:00 2001 From: Leyla Becker Date: Tue, 7 Jan 2025 15:59:31 -0600 Subject: [PATCH] added host option to rebuild script --- rebuild.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rebuild.sh b/rebuild.sh index a4b7fdc..45dae64 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -15,7 +15,7 @@ while [ $# -gt 0 ]; do if [[ "$1" != *=* ]]; then shift; fi # Value is next arg if no `=` target="${1#*=}" ;; - --flake*|-h*) + --flake*|-f*) if [[ "$1" != *=* ]]; then shift; fi flake="${1#*=}" ;; @@ -27,6 +27,10 @@ while [ $# -gt 0 ]; do if [[ "$1" != *=* ]]; then shift; fi user="${1#*=}" ;; + --host*) + if [[ "$1" != *=* ]]; then shift; fi + host="${1#*=}" + ;; --preserve-result) preserve_result=true ;; @@ -42,6 +46,7 @@ while [ $# -gt 0 ]; do echo "--flake -f: set the flake to rebuild on the target system" echo "--mode -m: set the mode to rebuild flake as on the target system" echo "--user -u: set the user to rebuild flake as on the target system" + echo "--host: set the host that the flake will be rebuilt on (unset for current machine)" echo "--preserve-result: do not remove the generated result folder after building" echo "--no-preserve-result: remove any result folder after building" echo "--show-trace: show trace on builds" @@ -62,6 +67,11 @@ user=${user:-$USER} command="nixos-rebuild $mode --use-remote-sudo --flake .#$flake" +if [[ $host ]]; +then + command="$command --build-host $host" +fi + if [[ "$target" != "$(hostname)" ]]; then command="$command --target-host $user@$target" @@ -72,6 +82,7 @@ then command="$command --show-trace" fi +echo $command $command if [ -d "result" ];