21 lines
648 B
Nix
21 lines
648 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..15}; do
|
|
if ip addr show dev tailscale0 | grep -q 'inet '; then break; fi
|
|
echo "$i"
|
|
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";
|
|
}
|