config/modules/services/tailscale/default.nix

49 lines
1.0 KiB
Nix
Raw Normal View History

{
config,
lib,
myData,
...
2024-07-29 12:39:54 +00:00
}:
let
cfg = config.mj.services.tailscale;
2024-07-29 12:39:54 +00:00
inherit (lib)
mkMerge
types
mkEnableOption
mkOption
mkIf
;
in
{
options.mj.services.tailscale = with types; {
enable = mkEnableOption "Enable tailscale";
2024-11-21 04:50:25 +00:00
acceptDNS = mkOption {
type = bool;
default = false;
};
# https://github.com/tailscale/tailscale/issues/1548
2023-10-22 20:06:06 +00:00
verboseLogs = mkOption {
type = bool;
2023-10-22 20:06:06 +00:00
default = false;
};
};
2023-10-01 20:14:05 +00:00
config = mkIf cfg.enable (mkMerge [
{
2024-03-05 09:39:10 +00:00
services.tailscale = {
enable = true;
2024-11-21 04:50:25 +00:00
extraUpFlags = [
"--operator=${config.mj.username}"
2024-11-21 04:54:12 +00:00
];
extraSetFlags = [
"--accept-dns=${if cfg.acceptDNS then "true" else "false"}"
2025-01-17 13:39:52 +00:00
"--accept-routes=true"
2024-11-21 04:50:25 +00:00
];
2024-03-05 09:39:10 +00:00
};
2023-09-14 11:48:54 +00:00
networking.firewall.checkReversePath = "loose";
2024-07-29 12:39:54 +00:00
networking.firewall.allowedUDPPorts = [ myData.ports.tailscale ];
}
2024-07-29 12:39:54 +00:00
(mkIf (!cfg.verboseLogs) { systemd.services.tailscaled.serviceConfig.StandardOutput = "null"; })
]);
}