Files
nix/modules/system/tailscale/default.nix
2025-11-12 21:10:22 -06:00

40 lines
1001 B
Nix

{
pkgs,
config,
lib,
...
}: let
cfg = config.system.tailscale;
authkey_file = config.sops.secrets."tailscale_authkey".path;
in {
options.system.tailscale = {
enable = lib.mkEnableOption "enables tailscale";
};
config = lib.mkIf cfg.enable {
services.tailscale = {
enable = true;
useRoutingFeatures = "both";
#authKeyFile = authkey_file;
extraSetFlags = [
"--accept-routes=true" # true is equilivant to useRoutingFeatures = "client" (breaks shit)
"--accept-dns=true" # explicitly allow resolved
];
};
systemd.services.tailscaled = {
after = [ "remote-fs.target" ]; # keep tailscale up until remote mounts are unmounted
};
# network config
networking.firewall.trustedInterfaces = ["tailscale0"];
networking.firewall.allowedUDPPorts = [config.services.tailscale.port];
# declare authkey secrets
sops.secrets = {
"tailscale_authkey" = {
owner = "root";
};
};
};
}