fix(vpn): fix autoconnect issues

This commit is contained in:
Felix Schröter 2024-01-21 21:40:27 +01:00
parent e514664004
commit d0bccd67bd
Signed by: felschr
GPG key ID: 671E39E6744C807D

View file

@ -3,6 +3,8 @@
let let
cfg = config.services.tailscale; cfg = config.services.tailscale;
tailscaleInterface = cfg.interfaceName; tailscaleInterface = cfg.interfaceName;
inherit (config.networking) hostName;
tailnetHost = "${hostName}.tail05275.ts.net";
in { in {
networking.wireguard.enable = true; networking.wireguard.enable = true;
networking.firewall.trustedInterfaces = [ tailscaleInterface ]; networking.firewall.trustedInterfaces = [ tailscaleInterface ];
@ -27,7 +29,10 @@ in {
systemd.services.tailscaled-autoconnect.script = '' systemd.services.tailscaled-autoconnect.script = ''
status=$(${config.systemd.package}/bin/systemctl show -P StatusText tailscaled.service) status=$(${config.systemd.package}/bin/systemctl show -P StatusText tailscaled.service)
if [[ $status != Connected* ]]; then if [[ $status != Connected* ]]; then
${cfg.package}/bin/tailscale up ${lib.escapeShellArgs cfg.extraUpFlags} ${cfg.package}/bin/tailscale up
fi fi
# some options cannot be set immediately
${cfg.package}/bin/tailscale up ${lib.escapeShellArgs cfg.extraUpFlags}
''; '';
} }