blob: 8e79dc7880e45c8b57f9fcf82eaee9f621fb996a (
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
|
self:
{
config,
lib,
pkgs,
spacebar,
...
}:
let
cfg = config.services.spacebarchat-server;
configFile = (import ./config-file.nix { inherit config lib pkgs; });
makeServerTsService = import ../../lib/makeServerTsService.nix { inherit cfg lib; };
in
{
options.services.spacebarchat-server = {
extraGatewayPorts = lib.mkOption {
type = lib.types.listOf lib.types.port;
description = "Extra gateway ports";
default = [ ];
};
};
config = lib.mkIf cfg.enable {
systemd.services = builtins.listToAttrs (
map (port: {
name = "spacebar-gateway-${toString port}";
value = makeServerTsService {
description = "Spacebar Server - Gateway (extra port ${toString port})";
# after = [ "spacebar-api.service" ];
environment = builtins.mapAttrs (_: val: builtins.toString val) (
{
# things we set by default...
EVENT_TRANSMISSION = "unix";
EVENT_SOCKET_PATH = "/run/spacebar/";
}
// cfg.extraEnvironment
// {
# things we force...
CONFIG_PATH = configFile;
CONFIG_READONLY = 1;
PORT = toString port;
STORAGE_LOCATION = cfg.cdnPath;
APPLY_DB_MIGRATIONS = "false";
}
);
serviceConfig = {
ExecStart = "${cfg.package}/bin/start-gateway";
};
};
}) cfg.extraGatewayPorts
);
};
}
|