Added tailscale config
This commit is contained in:
parent
c1adac59c4
commit
954d01d4fe
5 changed files with 59 additions and 53 deletions
50
modules/services/tailscale/default.nix
Normal file
50
modules/services/tailscale/default.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
options,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.aa.services.tailscale;
|
||||
in {
|
||||
options.aa.services.tailscale = with types; {
|
||||
enable = mkEnableOption "tailscale";
|
||||
configureClientRouting = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = mdDoc ''
|
||||
Configures tailscale as a client.
|
||||
|
||||
See `options.services.tailscale.useRoutingFeatures` for more information.
|
||||
'';
|
||||
};
|
||||
configureServerRouting = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = mdDoc ''
|
||||
Configures tailscale as a server.
|
||||
|
||||
See `options.services.tailscale.useRoutingFeatures` for more information.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment.systemPackages = [pkgs.tailscale];
|
||||
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"
|
||||
)
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue