My nix-darwin and NixOS config
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: make tailscale-ready non-fatal during nixos-rebuild

During switch, tailscaled gets restarted and the interface temporarily
disappears. The service was failing the rebuild even though Caddy's
Restart=always handles this gracefully.

- Remove bindsTo (was causing restart loops during switch)
- Exit 0 on timeout — log warning instead of failing
- Caddy will retry until the interface is available

👾 Generated with [Letta Code](https://letta.com)

Co-Authored-By: Letta Code <noreply@letta.com>

+5 -12
+5 -12
modules/server/infra/network/caddy.nix
··· 37 37 38 38 # ── Wait for Tailscale interface to be ready ─────────────────────────────── 39 39 # tailscaled.service starting doesn't mean the interface has its IP yet. 40 - # This service blocks until the Tailscale interface is up and has the expected IP. 40 + # This service waits for the interface, but doesn't fail if it times out — 41 + # Caddy has Restart=always and will retry until the interface is available. 41 42 systemd.services.tailscale-ready = lib.mkIf hasTailnet { 42 43 description = "Wait for Tailscale interface to be ready"; 43 44 after = [ "tailscaled.service" ]; 44 - bindsTo = [ "tailscaled.service" ]; 45 45 wantedBy = [ "multi-user.target" ]; 46 46 before = [ "caddy.service" ]; 47 47 serviceConfig = { ··· 50 50 }; 51 51 script = '' 52 52 echo "Waiting for Tailscale interface to be ready..." 53 - for i in $(seq 1 60); do 54 - # Check if tailscale0 exists with the expected IP 53 + for i in $(seq 1 30); do 55 54 if ip addr show tailscale0 2>/dev/null | grep -q "${cfg.server.tailscaleIP}"; then 56 55 echo "Tailscale interface ready with IP ${cfg.server.tailscaleIP}" 57 56 exit 0 58 57 fi 59 - # If tailscaled is still starting/restarting, wait for it 60 - if systemctl is-active --quiet tailscaled.service; then 61 - echo "tailscaled is active, waiting for interface..." 62 - else 63 - echo "tailscaled not yet active, waiting..." 64 - fi 65 58 sleep 1 66 59 done 67 - echo "Timed out waiting for Tailscale interface" 68 - exit 1 60 + echo "Timed out waiting for Tailscale interface — Caddy will retry" 61 + exit 0 69 62 ''; 70 63 }; 71 64