summary refs log tree commit diff
path: root/nixos/modules/services/networking/tailscale.nix
blob: d6684d69e615d4e6204dc7bb0ecc1ce538919bd8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{ config, lib, pkgs, ... }:

with lib;

let cfg = config.services.tailscale;
in {
  meta.maintainers = with maintainers; [ danderson mbaillie ];

  options.services.tailscale = {
    enable = mkEnableOption "Tailscale client daemon";

    port = mkOption {
      type = types.port;
      default = 41641;
      description = "The port to listen on for tunnel traffic (0=autoselect).";
    };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = [ pkgs.tailscale ]; # for the CLI
    systemd.packages = [ pkgs.tailscale ];
    systemd.services.tailscaled = {
      wantedBy = [ "multi-user.target" ];
      serviceConfig.Environment = "PORT=${toString cfg.port}";
    };
  };
}