bin/hey push: clean up/stop redundant sudo prompts
This commit is contained in:
parent
dd62442c09
commit
3d3497d9e9
49
bin/hey
49
bin/hey
|
@ -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}
|
||||||
|
@ -136,38 +136,37 @@ function main {
|
||||||
cmd="$1"
|
cmd="$1"
|
||||||
[[ $# > 0 ]] && shift
|
[[ $# > 0 ]] && shift
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
sh|shell) _do nix develop "$DOTFILES" "$@" ;;
|
sh|shell) _do nix develop "$DOTFILES" "$@" ;;
|
||||||
repl) _do nix repl "$DOTFILES/flake.nix" "<nixpkgs>" "$@" ;;
|
repl) _do nix repl "$DOTFILES/flake.nix" "<nixpkgs>" "$@" ;;
|
||||||
|
|
||||||
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 $@ ;;
|
||||||
gc) _gc "$@" ;;
|
gc) _gc "$@" ;;
|
||||||
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)
|
||||||
|
|
Loading…
Reference in a new issue