nix-stuff/roles/server/tailscale.nix

21 lines
669 B
Nix

{pkgs, ...}: let
script = pkgs.writeShellApplication {
name = "tailscale-wait-for-ip";
runtimeInputs = [pkgs.iproute2];
text = ''
# Based on https://github.com/tailscale/tailscale/issues/11504#issuecomment-2113331262
echo Waiting for tailscale0 to get an IP adress..
for i in {1..120}; do
if ip addr show dev tailscale0 | grep -q 'inet '; then break; fi
echo "Waiting $i/120 seconds"
sleep 1
done
'';
};
in {
services.tailscale = {
# This is needed for being an exit node
useRoutingFeatures = "server";
};
systemd.services.tailscaled.postStart = "${script}/bin/tailscale-wait-for-ip";
}