summaryrefslogtreecommitdiff
path: root/Omni/Ide
diff options
context:
space:
mode:
authorBen Sima <ben@bensima.com>2025-12-18 13:54:30 -0500
committerBen Sima <ben@bensima.com>2025-12-18 13:54:30 -0500
commit024461fcfb03981ccb474b2361d4b1a42586b5e5 (patch)
treef1623d11dfe528f36ed36ffa06309837bc0d14f3 /Omni/Ide
parentbd7724068938daa44dc74c28ab0aa5c45477bbfd (diff)
Telegram formatting + push.sh Tailscale support
- Strengthen Telegram MarkdownV2 formatting guidance in Ava's system prompt - Add DNS record beryl.bensima.com -> 100.127.197.132 (Tailscale IP) - Modify push.sh to detect local deploys and skip SSH - Add Tailscale hostname fallback when domain is unreachable
Diffstat (limited to 'Omni/Ide')
-rwxr-xr-xOmni/Ide/push.sh65
1 files changed, 47 insertions, 18 deletions
diff --git a/Omni/Ide/push.sh b/Omni/Ide/push.sh
index f6d67f4..a713e46 100755
--- a/Omni/Ide/push.sh
+++ b/Omni/Ide/push.sh
@@ -48,24 +48,53 @@ nixos_deploy() {
# hack: get the domain from the systemd service
where=$(rg --only-matching --replace '$2' --regexp '(domainname ")(.*)(")' \
"$what/etc/systemd/system/domainname.service")
- nix copy --to ssh://"$USER"@"$where" "$what"
- ssh "$USER"@"$where" sudo nix-env --profile /nix/var/nix/profiles/system --set "$what"
- switch_cmd=(
- systemd-run
- -E LOCALE_ARCHIVE
- --setenv=XDG_RUNTIME_DIR=""
- --collect
- --no-ask-password
- --pipe
- --quiet
- --service-type=exec
- --unit=push-switch-to-configuration
- --wait
- "$what/bin/switch-to-configuration"
- "switch"
- )
- # shellcheck disable=SC2029
- ssh "$USER"@"$where" sudo "${switch_cmd[@]}"
+
+ # Check if we're deploying to ourselves (local deploy)
+ # Extract hostname from NixOS config path (e.g., Omni.Dev.Beryllium.nix -> beryllium)
+ local current_hostname
+ current_hostname=$(hostname)
+ local config_hostname
+ config_hostname=$(echo "$target" | sed -E 's/.*\.([^.]+)\.nix$/\1/' | tr '[:upper:]' '[:lower:]')
+
+ if [[ "$current_hostname" == "$config_hostname" ]] || [[ "$where" == "localhost" ]]; then
+ echo -e "${YLW}info: push: local deploy detected${NC}"
+ sudo nix-env --profile /nix/var/nix/profiles/system --set "$what"
+ switch_cmd=(
+ "$what/bin/switch-to-configuration"
+ "switch"
+ )
+ sudo "${switch_cmd[@]}"
+ else
+ # Try domain first, fall back to Tailscale hostname (config_hostname)
+ local ssh_target="$USER@$where"
+ if ! ssh -o ConnectTimeout=5 -o BatchMode=yes "$ssh_target" true 2>/dev/null; then
+ echo -e "${YLW}info: push: $where unreachable, trying Tailscale hostname $config_hostname${NC}"
+ ssh_target="$USER@$config_hostname"
+ if ! ssh -o ConnectTimeout=5 -o BatchMode=yes "$ssh_target" true 2>/dev/null; then
+ echo -e "${RED}fail: push: cannot reach $where or $config_hostname${NC}"
+ exit 1
+ fi
+ fi
+
+ nix copy --to ssh://"$ssh_target" "$what"
+ ssh "$ssh_target" sudo nix-env --profile /nix/var/nix/profiles/system --set "$what"
+ switch_cmd=(
+ systemd-run
+ -E LOCALE_ARCHIVE
+ --setenv=XDG_RUNTIME_DIR=""
+ --collect
+ --no-ask-password
+ --pipe
+ --quiet
+ --service-type=exec
+ --unit=push-switch-to-configuration
+ --wait
+ "$what/bin/switch-to-configuration"
+ "switch"
+ )
+ # shellcheck disable=SC2029
+ ssh "$ssh_target" sudo "${switch_cmd[@]}"
+ fi
echo -e "${GRN}good: push: $target${NC}"
}