2021-07-13 23:48:41 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.my.services.tailscale;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.tailscale = {
|
|
|
|
enable = lib.mkEnableOption "Tailscale";
|
2021-07-14 00:08:40 +02:00
|
|
|
|
|
|
|
# NOTE: still have to do `tailscale up --advertise-exit-node`
|
|
|
|
exitNode = lib.mkEnableOption "Use as exit node";
|
2021-07-13 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.tailscale = {
|
|
|
|
enable = true;
|
2021-08-19 23:34:41 +02:00
|
|
|
package = pkgs.tailscale;
|
2021-07-13 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall = {
|
|
|
|
trustedInterfaces = [ "tailscale0" ];
|
|
|
|
allowedUDPPorts = [ config.services.tailscale.port ];
|
|
|
|
};
|
|
|
|
|
|
|
|
# enable IP forwarding to use as exit node
|
2021-07-14 00:08:40 +02:00
|
|
|
boot.kernel.sysctl = mkIf cfg.exitNode {
|
2021-07-13 23:48:41 +02:00
|
|
|
"net.ipv6.conf.all.forwarding" = true;
|
|
|
|
"net.ipv4.ip_forward" = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|