aboutsummaryrefslogtreecommitdiff
path: root/instance-options.nix
blob: 58cc99e7de0904ec578beb99fe95d68a4b45bfc0 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Configuration options specific to a single workadventure instance.

{ lib, pkgs, config, ... }:

with lib;
let workadventure = import ./workadventure-nix.nix { inherit lib pkgs; };
in
{
  options = rec {
    backend = {
      httpPort = mkOption {
        default = 8081;
        type = types.ints.u16;
        description = "The TCP port the backend will bind to for http";
      };

      grpcPort = mkOption {
        default = 50051;
        type = types.ints.u16;
        description = "The TCP port the backend will bind to for grpc";
      };

      package = mkOption {
        default = workadventure.back;
        defaultText = "third_party.workadventure-nix.back";
        type = types.package;
        description = "Backend package to use";
      };
    };

    pusher = {
      port = mkOption {
        default = 8080;
        type = types.ints.u16;
        description = "The TCP port the pusher will bind to";
      };

      package = mkOption {
        default = workadventure.pusher;
        defaultText = "third_party.workadventure-nix.pusher";
        type = types.package;
        description = "Pusher package to use";
      };
    };

    frontend = {
      package = mkOption {
        default = workadventure.front;
        defaultText = "third_party.workadventure-nix.front";
        type = types.package;
        description = "Front package to use";
      };
      
      defaultMap = mkOption {
        default = null;
        defaultText = "not set";
        type = types.nullOr types.str;
        description = "The url to the default map, which will be loaded if none is given in the url. Must be a reachable url relative to the public map url defined in `maps.url`.";
      };
      
      settings = mkOption {
        default = {};
        type = types.attrsOf types.str;
        description = "Settings for workadventure's frontend.";
        example =  {
          stunServer = "stun:some.stunserver:3478";
          turnServer = "turn:some.turnserver";
          turnUser = "user";
          turnPassword = "password";
        };

      };

      urls = {
        api = mkOption {
          default = "/pusher";
          type = types.str;
          description = "The base url for the api, from the browser's point of view";
        };

        uploader = mkOption {
          default = "/uploader";
          type = types.str;
          description = "The base url for the uploader, from the browser's point of view";
        };

        admin = mkOption {
          default = "/admin";
          type = types.str;
          description = "The base url for the admin, from the browser's point of view";
        };

        maps = mkOption {
          default = "/maps";
          type = types.str;
          description = "The base url for serving maps, from the browser's point of view";
        };
      };
    };

    maps = {
      path = mkOption {
        default = workadventure.maps.outPath + "/workadventuremaps/";
        defaultText = "third_party.workadventure-nix.maps";
        type = types.path;
        description = "Maps package to use";
      };
    };

    nginx = {
      default = mkOption {
        default = false;
        type = types.bool;
        description = "Whether this instance will be the default one served by nginx";
      };

      domain = mkOption {
        default = null;
        type = types.nullOr types.str;
        description = "The domain name to serve workadenture services under. Mutually exclusive with domains.X";
      };

      serveDefaultMaps = mkOption {
        default = true;
        type = types.bool;
        description = "Whether to serve the maps provided by workadventure";
      };

      domains = {
        back = mkOption {
          default = null;
          type = types.nullOr types.str;
          description = "The domain name to serve the backend under";
        };

        pusher = mkOption {
          default = null;
          type = types.nullOr types.str;
          description = "The domain name to serve the pusher under";
        };

        maps = mkOption {
          default = null;
          type = types.nullOr types.str;
          description = "The domain name to serve the maps under";
        };

        front = mkOption {
          default = null;
          type = types.nullOr types.str;
          description = "The domain name to serve the front under";
        };
      };
    };
  };
}