Files
nix/modules/homelab/network/tailscale/default.nix
T
2026-06-14 08:36:27 -05:00

41 lines
982 B
Nix

{
pkgs,
config,
lib,
...
}: let
cfg = config.homelab.tailscale;
sec = config.sops.secrets;
in {
options.homelab.tailscale = {
enable = lib.mkEnableOption "enables tailscale";
};
config = lib.mkIf cfg.enable {
services.tailscale = {
enable = true;
openFirewall = true;
useRoutingFeatures = "both";
authKeyFile = sec."tailscale_authkey".path;
extraSetFlags = [
"--advertise-routes=${config.homelab.host_ip}/32" # advertise self
"--accept-routes=false" # true is equilivant to useRoutingFeatures = "client" (breaks shit)
"--accept-dns=true" # explicitly allow resolved
];
extraUpFlags = [
];
};
# network config
networking.firewall.trustedInterfaces = ["tailscale0"];
networking.firewall.allowedUDPPorts = [config.services.tailscale.port];
# declare authkey secrets
sops.secrets = {
"tailscale_authkey" = {
owner = "root";
};
};
};
}