From f98de53f02ff9e0371060e88926d96664eaa5945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=BF=20corey?= Date: Mon, 11 May 2026 16:45:18 -0700 Subject: [PATCH] feat(lobtop): add launchd agent for Warp/Tailscale conflict fix Adds a home-manager launchd user agent that re-runs the restore-warp-tailscale script whenever Cloudflare WARP updates its app bundle (via WatchPaths). Also runs at load. Configures split-tunnel exclusion for 100.64.0.0/10 and DNS fallback domains ts.net and ts.zx.dev. Co-Authored-By: Claude Sonnet 4.6 --- hosts/lobtop/home.nix | 51 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/hosts/lobtop/home.nix b/hosts/lobtop/home.nix index 803a42a7..12032554 100644 --- a/hosts/lobtop/home.nix +++ b/hosts/lobtop/home.nix @@ -1,3 +1,52 @@ -{pkgs, ...}: { +{pkgs, ...}: let + restoreScript = pkgs.writeShellScript "restore-warp-tailscale" '' + WARP=/usr/local/bin/warp-cli + + IP_RANGES=("100.64.0.0/10") + DNS_DOMAINS=("ts.net" "ts.zx.dev") + + log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"; } + + apply_ip_ranges() { + local existing + existing=$("$WARP" tunnel ip list 2>/dev/null) + for range in "''${IP_RANGES[@]}"; do + if echo "$existing" | grep -qF "$range"; then + log "IP range already present: $range" + else + "$WARP" tunnel ip add-range "$range" 2>/dev/null && log "Added IP range: $range" + fi + done + } + + apply_dns_fallbacks() { + local existing + existing=$("$WARP" dns fallback list 2>/dev/null) + for domain in "''${DNS_DOMAINS[@]}"; do + if echo "$existing" | grep -qF "$domain"; then + log "DNS fallback already present: $domain" + else + "$WARP" dns fallback add "$domain" 2>/dev/null && log "Added DNS fallback: $domain" + fi + done + } + + log "Starting WARP/Tailscale restore" + apply_ip_ranges + apply_dns_fallbacks + log "Done" + ''; +in { rc.gpg.enable = true; + + launchd.agents."com.user.restore-warp-tailscale" = { + enable = true; + config = { + ProgramArguments = ["${restoreScript}"]; + WatchPaths = ["/Applications/Cloudflare WARP.app/Contents/Resources"]; + RunAtLoad = true; + StandardOutPath = "/tmp/restore-warp-tailscale.log"; + StandardErrorPath = "/tmp/restore-warp-tailscale.log"; + }; + }; }