Files
nix/modules/homelab/tailscale/default.nix

41 lines
985 B
Nix

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