nixos-config/system/vpn.nix

34 lines
922 B
Nix
Raw Normal View History

{ config, lib, ... }:
2020-05-22 18:16:21 +02:00
let
cfg = config.services.tailscale;
tailscaleInterface = cfg.interfaceName;
2023-12-27 18:03:57 +01:00
in {
networking.wireguard.enable = true;
2023-12-27 18:03:57 +01:00
networking.firewall.trustedInterfaces = [ tailscaleInterface ];
2023-12-27 18:03:57 +01:00
services.tailscale = {
enable = true;
authKeyFile = "/dummy";
2023-12-27 18:03:57 +01:00
openFirewall = true;
useRoutingFeatures = "both";
extraUpFlags = [
"--reset"
"--accept-routes"
2024-01-12 20:46:03 +01:00
"--exit-node-allow-lan-access"
"--exit-node=de-ber-wg-004.mullvad.ts.net"
];
2023-12-27 18:03:57 +01:00
};
2024-01-12 20:46:03 +01:00
systemd.services.tailscaled.serviceConfig.Environment =
[ "TS_DEBUG_FIREWALL_MODE=auto" ];
# call taiscale up without --auth-key
systemd.services.tailscaled-autoconnect.script = ''
status=$(${config.systemd.package}/bin/systemctl show -P StatusText tailscaled.service)
if [[ $status != Connected* ]]; then
${cfg.package}/bin/tailscale up ${lib.escapeShellArgs cfg.extraUpFlags}
fi
'';
2020-05-22 18:16:21 +02:00
}