Basically a rich man's version of this poor man's bash script:
while ! tailscale status --json | jq --exit-status '.Self.Online' >/dev/null
sleep 1
doneBlock until tailscale reaches an online or offline state. Returns immediately if its already in its desired state.
$ wait4tailscale --online
$ wait4tailscale --offline
Or watch a log of all changes
$ wait4tailscale --watch
online
offline
online
Will automatically detect the default socket location, but otherwise a socket can be explicitly given.
$ wait4tailscale --socket /var/run/tailscale/tailscaled.sock
The package includes systemd units that provide a tailscale-online.target similar to network-online.target. Other services can depend on this target to wait for Tailscale connectivity:
[Unit]
After=tailscale-online.target
Wants=tailscale-online.targetPackaged under josh/nurpkgs flake. Use the systemd units in your NixOS config with something like this:
systemd.packages = [ pkgs.nur.repos.josh.wait4tailscale ];