aboutsummaryrefslogtreecommitdiff
path: root/instance-options.nix
blob: c01932ed2983bf8209f844e24e4b413a8100472d (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# Configuration options specific to a single workadventure instance.

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

with lib;
with pkgs;
{
  options = rec {

    packageset = mkOption {
      default = workadventure-tcm;
      type = types.attrs;
      description = "The package set to use. It should contain a front, backend, pusher, and maps package.";
    };

    backend = {
      enable = mkOption {
        default = true;
        type = types.bool;
      };
      
      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";
      };
    };

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

    frontend = {
      debugMode = mkOption {
        default = false;
        description = "Whether or not to run the frontend in debug mode";
        type = types.bool;
      };
      
      startRoomUrl = mkOption {
        default = "/_/global/localhost/maps/Floor0/floor0.json";
        description = "The workadventure map url that users join by default";
        type = types.str;
      };
      
      resolution = mkOption {
        default = 2;
        description = "resolution of workadventure";
        type = types.int;
      };
      
      zoomLevel = mkOption {
        default = 1;
        description = "The default zoom level of maps";
        type = types.int;
      };
      
      positionDelay = mkOption {
        default = 200;
        description = "Delay in milliseconds between sending position events";
        type = types.int;
      };
      
      maxExtrapolationTime = mkOption {
        default = 100;
        description = "Maximum time period in which movements of other players are extrapolated";
        type = types.int;
      };
      
      
      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 = "/pusher/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";
        };
      };
    };

    commonConfig = {
      secretKey = mkOption {
        default = "THECODINGMACHINE_SECRET_KEY";
        type = types.str;
      };
      
      minimumDistance = mkOption {
        default = 64;
        type = types.int;
      };
      
      groupRadius = mkOption {
        default = 48;
        type = types.int;
      };
      
      allowArtillery = mkOption {
        default = false;
        type = types.bool;
      };
      
      maxUsersPerRoom = mkOption {
        default = 600;
        type = types.int;
      };
      
      cpuOverheatThreshold = mkOption {
        default = 80;
        type = types.int;
      };
    
      socketIdleTime = mkOption {
        default = 30;
        type = types.int;
      };  
    
      webrtc = {
        stun = {
          url = mkOption {
            default = "stun:stun.l.google.com:19302";
            description = "The STUN server to use for peer connections";
            type = types.str;
          };
        };
        turn = {
          url = mkOption {
            default = "turn:coturn.workadventure.localhost:3478";
            description = "The TURN server to use for peer connections";
            type = types.str;
          };
          user = mkOption {
            default = "workadventure";
            description = "Username for TURN authentication";
            type = types.str; # TODO: also allow no user
          };
          password = mkOption {
            default = "workadventure";
            description = "Password for TURN authentication";
            type = types.str;
          };
        };
      };
      
      jitsi = {
        url = mkOption {
          default = "meet.jit.si";
          description = "Jitsi instance to use for conference rooms";
          type = types.str;
        };
        privateMode = mkOption {
          default = false;
          description = "Jitsi private mode";
          type = types.bool;
        };
        iss = mkOption {
          default = "";
          type = types.str;
        };
        secretKey = mkOption {
          default = "";
          type = types.str;
        };
      };
    };


    nginx = {
      enable = mkOption {
        default = true;
        type = types.bool;
        description = "enable nginx as proxy, and for serving maps";
      };
    
      default = mkOption {
        default = false;
        type = types.bool;
        description = "Whether this instance will be the default one served by nginx";
      };

      domain = mkOption {
        default = "localhost";
        type = types.str;
        description = "The domain name to serve workadenture services under.";
      };

      maps = {
        serve = mkOption {
          default = true;
          type = types.bool;
          description = "Whether to serve maps through nginx.";
        };
        path = mkOption {
          default = workadventure-tcm.maps.outPath + "/workadventuremaps/";
          type = types.nullOr types.path;
          description = "Path to a directory which should be served under /maps. If maps are enabled and this path set to null, the default maps provided in the packageset are used instead.";
        };
      };
    };
  };
}