bin/hey push: clean up/stop redundant sudo prompts

This commit is contained in:
Henrik Lissner 2021-01-21 00:18:52 -05:00
parent dd62442c09
commit 3d3497d9e9

21
bin/hey
View file

@ -65,7 +65,7 @@ function main {
# Move to $DOTFILES to prevent polluting the system with result links # Move to $DOTFILES to prevent polluting the system with result links
pushd $DOTFILES >/dev/null pushd $DOTFILES >/dev/null
# REVIEW Use --impure instead when it's in a stable release of nix # REVIEW Use --impure instead when it's in a stable release of nix
_do sudo nixos-rebuild \ _do nixos-rebuild \
--flake "${DOTFILES}#${HOSTNAME:-$HOST}" \ --flake "${DOTFILES}#${HOSTNAME:-$HOST}" \
--option pure-eval no \ --option pure-eval no \
${@:-build} ${@:-build}
@ -142,14 +142,14 @@ function main {
ch|check) _do nix flake check "$@" "$DOTFILES" ;; ch|check) _do nix flake check "$@" "$DOTFILES" ;;
sh|show) _do nix flake show "$@" "$DOTFILES" ;; sh|show) _do nix flake show "$@" "$DOTFILES" ;;
theme) THEME="$1" _rebuild --fast test ;; theme) THEME="$1" sudo _rebuild --fast test ;;
t|test) _rebuild --fast test "$@" ;; t|test) sudo _rebuild --fast test "$@" ;;
re|rebuild) _rebuild "${@:-switch}" ;; re|rebuild) sudo _rebuild "${@:-switch}" ;;
rollback) _rebuild --rollback switch ;; rollback) sudo _rebuild --rollback switch ;;
vm) _rebuild "$@" vm ;; vm) sudo _rebuild "$@" vm ;;
u|update) _update "$@" ;; u|update) _update "$@" ;;
up|upgrade) _update && _rebuild switch ;; up|upgrade) _update && sudo _rebuild switch ;;
s|search) nix search nixpkgs "$@" ;; s|search) nix search nixpkgs "$@" ;;
swap) _swap $@ ;; swap) _swap $@ ;;
@ -157,17 +157,16 @@ function main {
push) push)
target=$1 target=$1
cmd=${2:-test} cmd=${2:-test}
# build then ssh in to switch/boot/test so we don't require root ssh
# access on the remote.
echo "Enabling root ssh access on $target" echo "Enabling root ssh access on $target"
ssh -t "$target" "sudo mkdir -p /root/.ssh && sudo cp -f ~/.ssh/authorized_keys /root/.ssh/" if _do ssh -t "$target" "sudo mkdir -p /root/.ssh && sudo cp -f ~/.ssh/authorized_keys /root/.ssh/authorized_keys"; then
echo "Building $target ($cmd)" echo "Building $target ($cmd)"
HOSTNAME="${HOSTNAME:-$target}" _rebuild \ HOSTNAME="${HOSTNAME:-$target}" _rebuild \
--build-host localhost \ --build-host localhost \
--target-host "root@$target" \ --target-host "root@$target" \
$cmd $cmd
echo "Undoing root ssh access on $target" echo "Undoing root ssh access on $target"
ssh -t "root@$target" "rm -f /root/.ssh/authorized_keys" _do ssh -t "root@$target" "rm -f /root/.ssh/authorized_keys"
fi
;; ;;
gen|generations) gen|generations)