dotfiles/modules/nixos/services/tailscale/default.nix

54 lines
1.3 KiB
Nix
Raw Normal View History

2023-03-25 16:58:31 +00:00
{
config,
pkgs,
lib,
...
}: let
inherit (lib) mkIf;
2023-03-25 16:58:31 +00:00
cfg = config.aa.services.tailscale;
in {
options.aa.services.tailscale = with lib; {
2023-03-25 16:58:31 +00:00
enable = mkEnableOption "tailscale";
configureClientRouting = mkOption {
type = types.bool;
2023-03-25 16:58:31 +00:00
default = false;
description = mdDoc ''
Configures tailscale as a client.
See `options.services.tailscale.useRoutingFeatures` for more information.
'';
};
configureServerRouting = mkOption {
type = types.bool;
2023-03-25 16:58:31 +00:00
default = false;
description = mdDoc ''
Configures tailscale as a server.
See `options.services.tailscale.useRoutingFeatures` for more information.
'';
};
};
config = mkIf cfg.enable {
2024-04-13 17:14:04 +00:00
environment.systemPackages = with pkgs; [
tailscale
tailscale-systray
];
2023-03-25 16:58:31 +00:00
networking.firewall.allowedUDPPorts = [config.services.tailscale.port];
services.tailscale = {
enable = true;
useRoutingFeatures = mkIf (cfg.configureClientRouting || cfg.configureServerRouting) (
if (cfg.configureClientRouting && cfg.configureServerRouting)
then "both"
else
(
if cfg.configureClientRouting
then "client"
else "server"
)
);
};
};
}