2022-04-10 11:54:58 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
2022-01-11 16:08:21 +01:00
|
|
|
mkEnableOption
|
|
|
|
mkIf
|
2023-12-13 17:43:53 +01:00
|
|
|
mkOption
|
|
|
|
types
|
2022-04-10 11:54:58 +02:00
|
|
|
;
|
2022-01-11 16:08:21 +01:00
|
|
|
|
2021-07-13 23:48:41 +02:00
|
|
|
cfg = config.my.services.tailscale;
|
2022-04-10 11:54:58 +02:00
|
|
|
in {
|
2021-07-13 23:48:41 +02:00
|
|
|
options.my.services.tailscale = {
|
2022-01-11 16:08:21 +01:00
|
|
|
enable = mkEnableOption "Tailscale";
|
2023-12-13 17:43:53 +01:00
|
|
|
useRoutingFeatures = mkOption {
|
|
|
|
type = types.enum ["none" "client" "server" "both"];
|
|
|
|
default = "none";
|
|
|
|
};
|
2021-07-13 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.tailscale = {
|
|
|
|
enable = true;
|
2021-08-19 23:34:41 +02:00
|
|
|
package = pkgs.tailscale;
|
2023-12-13 17:43:53 +01:00
|
|
|
openFirewall = true;
|
|
|
|
useRoutingFeatures = cfg.useRoutingFeatures;
|
2021-07-13 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall = {
|
2023-12-13 17:43:53 +01:00
|
|
|
trustedInterfaces = [config.services.tailscale.interfaceName];
|
2021-07-13 23:48:41 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|