diff options
-rw-r--r-- | common.sh | 34 | ||||
-rw-r--r-- | flake.lock | 12 |
2 files changed, 31 insertions, 15 deletions
@@ -35,16 +35,31 @@ sshdest() { awk -F- 'NF > 1 { print $2"."$1; exit } { print $1 }' <<<"$1" } +_sh() { + if [ $# -gt 1 ]; then + "$@" + else + sh -c "$1" + fi +} + _ssh() { local device="$1" shift if [ "$device" != "$(hostname)" ]; then - local -a args - [ "$1" = "sudo" ] && \ - args+=('-t') # Crude detection for terminal need - ssh "${args[@]}" "$(sshdest "$device")" -- "$@" + ssh "$(sshdest "$device")" -- "$@" else - "$@" + _sh "$@" + fi +} + +_tssh() { + local device="$1" + shift + if [ "$device" != "$(hostname)" ]; then + ssh -t "$(sshdest "$device")" -- "$@" + else + _sh "$@" fi } @@ -135,10 +150,11 @@ setenv() { info "-----------------------------------------------------------------" # TODO we should call here switch-to-configuration as well to use single # sudo session and remove one prompt. - _ssh "$device" \ - sudo sh -c \ - 'nix-env --profile /nix/var/nix/profiles/system --set "$store" && /nix/var/nix/profiles/system/bin/switch-to-configuration "$1"' \ - "$switchop" + local _store _switchop + printf -v _store '%q' "$store" + printf -v _switchop '%q' "$switchop" + _tssh "$device" \ + "sudo nix-env --profile /nix/var/nix/profiles/system --set '$_store' && sudo /nix/var/nix/profiles/system/bin/switch-to-configuration '$_switchop'" else warning "The latest system might have been already set." fi @@ -44,11 +44,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1659356074, - "narHash": "sha256-UwV6hZZEtchvtiTCCD/ODEv1226eam8kEgEyQb7xB0E=", + "lastModified": 1660030916, + "narHash": "sha256-KeVTmST6vAS85uUaSYlzv6OWhveawfIGhqX1SMq+L30=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "ea3efc80f8ab83cb73aec39f4e76fe87afb15a08", + "rev": "3975d5158f00accda15a11180b2c08654cfb2807", "type": "github" }, "original": { @@ -58,11 +58,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1659987637, - "narHash": "sha256-8l+5QiCkackVPu/F3vX7RCKHyYKxEsq/TKMuaG6UX5k=", + "lastModified": 1660017629, + "narHash": "sha256-Koz6/k7c6hx4qVz/bboxdR2QsBdkxjRWpNmsOWJtXZE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a47896bf817e7324471e687fc2bb2312fff682ce", + "rev": "9f15d6c3a74d2778c6e1af67947c95f100dc6fd2", "type": "github" }, "original": { |