This commit is contained in:
Lukas Wurzinger 2025-01-04 17:09:28 +01:00
parent 264de8a5e8
commit d9d40dcf09
No known key found for this signature in database

View file

@ -8,7 +8,7 @@ progname=$0
error() { error() {
for line in "$@"; do for line in "$@"; do
printf '%s\n' "$progname: $line" 1>&2 echo "$progname: $line" 1>&2
done done
exit 1 exit 1
@ -18,7 +18,7 @@ args=$(getopt --options f:o:t: --longoptions=flake:,on:,to: --name "$progname" -
eval set -- "$args" eval set -- "$args"
flake=git+https://forgejo@tea.wrz.one/lukas/puter.git#$(hostname) host=localhost
flags=( flags=(
--refresh --refresh
--use-remote-sudo --use-remote-sudo
@ -35,7 +35,8 @@ while true; do
shift 2 shift 2
;; ;;
(-t | --to) (-t | --to)
flags+=(--target-host "$2") host=$2
flags+=(--target-host "$host")
shift 2 shift 2
;; ;;
(-v | --verbose) (-v | --verbose)
@ -49,13 +50,21 @@ while true; do
esac esac
done done
if [[ ! -v flake ]]; then
flake=git+https://forgejo@tea.wrz.one/lukas/puter.git#$(ssh -- "$host" hostname)
fi
flags+=(--flake "$flake")
if (( $# == 0 )); then if (( $# == 0 )); then
error 'a subcommand is required' error 'a subcommand is required'
fi fi
subcommand=$1 sub=$1
case $subcommand in cmd=(nixos-rebuild "${flags[@]}")
case $sub in
(s | switch) (s | switch)
shift shift
@ -63,7 +72,9 @@ case $subcommand in
error 'too many arguments' error 'too many arguments'
fi fi
nixos-rebuild switch "${flags[@]}" --flake "$flake" cmd+=(switch)
echo "${cmd[@]}"
"${cmd[@]}"
;; ;;
(b | boot) (b | boot)
shift shift
@ -72,7 +83,9 @@ case $subcommand in
error 'too many arguments' error 'too many arguments'
fi fi
nixos-rebuild boot "${flags[@]}" --flake "$flake" cmd+=(boot)
echo "${cmd[@]}"
"${cmd[@]}"
;; ;;
(*) (*)
error 'invalid subcommand' error 'invalid subcommand'