blob: 2afbbbf99815fbe2bfeebbbf121bb62e5967d1ad (
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
|
{ systemConfig, lib, pkgs, ... }:
with lib;
types.submodule ({ config, name, ... }:
let
inherit (systemConfig.services.matrix-appservices)
homeserverDomain;
asFormats = (import ./as-formats.nix) {
inherit name lib pkgs systemConfig;
asConfig = config;
};
asFormat = asFormats.${config.format};
settingsFormat = pkgs.formats.json { };
in
{
options = rec {
format = mkOption {
type = types.enum (mapAttrsToList (n: _: n) asFormats);
default = "other";
description = ''
Format of the appservice, used to set option defaults for appservice.
This is usually determined by the library the appservice is based on.
Below are descriptions for each format
'' + (concatStringsSep "\n" (mapAttrsToList
(n: v: "${n}: ${v.description}")
asFormats));
};
package = mkOption {
type = types.nullOr types.package;
default = null;
example = "pkgs.mautrix-whatsapp";
description = ''
The package for the appservice. Used by formats except 'other'.
This is unecessary if startupScript is set.
'';
};
settings = mkOption rec {
type = settingsFormat.type;
apply = recursiveUpdate default;
default = asFormat.settings or { };
defaultText = "Format will attempt to configure database and allow homeserver users";
example = literalExpression ''
{
bridge = {
domain = "public-domain.tld";
homeserverUrl = "http://public-domain.tld:8008";
};
}
'';
description = ''
Appservice configuration as a Nix attribute set.
All environment variables will be substituted.
Including:
- $DIR which refers to the appservice's data directory.
- $AS_TOKEN, $HS_TOKEN which refers to the Appservice and
Homeserver registration tokens.
Secret tokens, should be specified in serviceConfig.EnvironmentFile
instead of this world-readable attribute set.
Configuration options should match those described as per your appservice's settings
Check out the confg sample for this.
'';
};
registrationData = mkOption {
type = settingsFormat.type;
default = asFormat.registrationData or {
namespaces = {
users = [
{
regex = "@${name}_.*:${homeserverDomain}";
exclusive = true;
}
{
regex = "@${name}bot:${homeserverDomain}";
exclusive = true;
}
];
};
};
defaultText = ''
Reserve usernames under the homeserver that start with
this appservice's name followed by an _ or "bot"
'';
description = ''
Data to set in the registration file for the appservice. The default
set or the format should usually deal with this.
'';
};
host = mkOption {
type = types.str;
default = "localhost";
description = ''
The host the appservice will listen on.
Will need to specified in config, but most formats will do it for you using
this option.
'';
};
port = mkOption {
type = types.port;
description = ''
The port the appservice will listen on.
Will need to specified in config, but most formats will do it for you using
this option.
'';
};
startupScript = mkOption {
type = types.str;
default = asFormat.startupScript or "";
description = ''
Script that starts the appservice.
The settings file will be available as $SETTINGS_FILE
and the registration file as $REGISTRATION_FILE
'';
};
serviceConfig = mkOption rec {
type = types.attrs;
apply = x: default // x;
default = asFormat.serviceConfig or { };
description = ''
Overrides for settings in the service's serviceConfig
'';
};
serviceDependencies = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
Services started before this appservice
'';
};
};
})
|