1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let cfg = config.services.tailscale;
6in {
7 meta.maintainers = with maintainers; [ danderson mbaillie ];
8
9 options.services.tailscale = {
10 enable = mkEnableOption "Tailscale client daemon";
11
12 port = mkOption {
13 type = types.port;
14 default = 41641;
15 description = "The port to listen on for tunnel traffic (0=autoselect).";
16 };
17
18 package = mkOption {
19 type = types.package;
20 default = pkgs.tailscale;
21 defaultText = "pkgs.tailscale";
22 description = "The package to use for tailscale";
23 };
24 };
25
26 config = mkIf cfg.enable {
27 environment.systemPackages = [ cfg.package ]; # for the CLI
28 systemd.packages = [ cfg.package ];
29 systemd.services.tailscaled = {
30 wantedBy = [ "multi-user.target" ];
31 path = [ pkgs.openresolv ];
32 serviceConfig.Environment = "PORT=${toString cfg.port}";
33 };
34 };
35}