2024-01-06 03:06:53 +01:00
|
|
|
{ config, lib, ... }:
|
2020-05-22 18:16:21 +02:00
|
|
|
|
2024-01-06 03:06:53 +01:00
|
|
|
let
|
|
|
|
cfg = config.services.tailscale;
|
|
|
|
tailscaleInterface = cfg.interfaceName;
|
2023-12-27 18:03:57 +01:00
|
|
|
in {
|
2020-11-14 11:20:59 +01:00
|
|
|
networking.wireguard.enable = true;
|
2023-12-27 18:03:57 +01:00
|
|
|
networking.firewall.trustedInterfaces = [ tailscaleInterface ];
|
2021-06-10 12:14:30 +02:00
|
|
|
|
2023-12-27 18:03:57 +01:00
|
|
|
services.tailscale = {
|
|
|
|
enable = true;
|
2024-01-06 03:06:53 +01:00
|
|
|
authKeyFile = "/dummy";
|
2023-12-27 18:03:57 +01:00
|
|
|
openFirewall = true;
|
|
|
|
useRoutingFeatures = "both";
|
2024-01-06 03:06:53 +01:00
|
|
|
extraUpFlags = [
|
|
|
|
"--reset"
|
|
|
|
"--accept-routes"
|
2024-01-12 20:46:03 +01:00
|
|
|
"--exit-node-allow-lan-access"
|
2024-01-06 03:06:53 +01:00
|
|
|
"--exit-node=de-ber-wg-004.mullvad.ts.net"
|
|
|
|
];
|
2023-12-27 18:03:57 +01:00
|
|
|
};
|
2022-08-08 22:58:02 +02:00
|
|
|
|
2024-01-12 20:46:03 +01:00
|
|
|
systemd.services.tailscaled.serviceConfig.Environment =
|
|
|
|
[ "TS_DEBUG_FIREWALL_MODE=auto" ];
|
|
|
|
|
2024-01-06 03:06:53 +01:00
|
|
|
# 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
|
2023-12-27 15:50:17 +01:00
|
|
|
'';
|
2020-05-22 18:16:21 +02:00
|
|
|
}
|