about summary refs log tree commit diff
path: root/nixos/modules/services/networking/netbird/server.nix
blob: a4de0fda6a1341e7e7296b636190055a311b3b87 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{ config, lib, ... }:

let
  inherit (lib)
    mkEnableOption
    mkIf
    mkOption
    optionalAttrs
    ;

  inherit (lib.types) str;

  cfg = config.services.netbird.server;
in

{
  meta = {
    maintainers = with lib.maintainers; [ thubrecht ];
    doc = ./server.md;
  };

  # Import the separate components
  imports = [
    ./coturn.nix
    ./dashboard.nix
    ./management.nix
    ./signal.nix
  ];

  options.services.netbird.server = {
    enable = mkEnableOption "Netbird Server stack, comprising the dashboard, management API and signal service";

    enableNginx = mkEnableOption "Nginx reverse-proxy for the netbird server services.";

    domain = mkOption {
      type = str;
      description = "The domain under which the netbird server runs.";
    };
  };

  config = mkIf cfg.enable {
    services.netbird.server = {
      dashboard = {
        inherit (cfg) enable domain enableNginx;

        managementServer = "https://${cfg.domain}";
      };

      management =
        {
          inherit (cfg) enable domain enableNginx;
        }
        // (optionalAttrs cfg.coturn.enable {
          turnDomain = cfg.domain;
          turnPort = config.services.coturn.tls-listening-port;
        });

      signal = {
        inherit (cfg) enable domain enableNginx;
      };

      coturn = {
        inherit (cfg) domain;
      };
    };
  };
}