1 { config, lib, pkgs, ... }:
3 cfg = config.services.jigasi;
4 homeDirName = "jigasi-home";
6 sipCommunicatorPropertiesFile = "${stateDir}/${homeDirName}/sip-communicator.properties";
7 sipCommunicatorPropertiesFileUnsubstituted = "${pkgs.jigasi}/etc/jitsi/jigasi/sip-communicator.properties";
10 options.services.jigasi = with lib.types; {
11 enable = lib.mkEnableOption "Jitsi Gateway to SIP - component of Jitsi Meet";
13 xmppHost = lib.mkOption {
15 example = "localhost";
17 Hostname of the XMPP server to connect to.
21 xmppDomain = lib.mkOption {
23 example = "meet.example.org";
25 Domain name of the XMMP server to which to connect as a component.
27 If null, <option>xmppHost</option> is used.
31 componentPasswordFile = lib.mkOption {
33 example = "/run/keys/jigasi-component";
35 Path to file containing component secret.
39 userName = lib.mkOption {
41 default = "callcontrol";
43 User part of the JID for XMPP user connection.
47 userDomain = lib.mkOption {
49 example = "internal.meet.example.org";
51 Domain part of the JID for XMPP user connection.
55 userPasswordFile = lib.mkOption {
57 example = "/run/keys/jigasi-user";
59 Path to file containing password for XMPP user connection.
63 bridgeMuc = lib.mkOption {
65 example = "jigasibrewery@internal.meet.example.org";
67 JID of the internal MUC used to communicate with Videobridges.
71 defaultJvbRoomName = lib.mkOption {
76 Name of the default JVB room that will be joined if no special header is included in SIP invite.
80 environmentFile = lib.mkOption {
81 type = lib.types.nullOr lib.types.path;
84 File containing environment variables to be passed to the jigasi service,
85 in which secret tokens can be specified securely by defining values for
86 <literal>JIGASI_SIPUSER</literal>,
87 <literal>JIGASI_SIPPWD</literal>,
88 <literal>JIGASI_SIPSERVER</literal> and
89 <literal>JIGASI_SIPPORT</literal>.
93 config = lib.mkOption {
96 example = lib.literalExpression ''
98 "org.jitsi.jigasi.auth.URL" = "XMPP:jitsi-meet.example.com";
102 Contents of the <filename>sip-communicator.properties</filename> configuration file for jigasi.
107 config = lib.mkIf cfg.enable {
108 services.jicofo.config = {
109 "org.jitsi.jicofo.jigasi.BREWERY" = "${cfg.bridgeMuc}";
112 services.jigasi.config = lib.mapAttrs (_: v: lib.mkDefault v) {
113 "org.jitsi.jigasi.BRIDGE_MUC" = cfg.bridgeMuc;
116 users.groups.jitsi-meet = {};
118 systemd.services.jigasi = let
120 "-Dnet.java.sip.communicator.SC_HOME_DIR_LOCATION" = "${stateDir}";
121 "-Dnet.java.sip.communicator.SC_HOME_DIR_NAME" = "${homeDirName}";
122 "-Djava.util.logging.config.file" = "${pkgs.jigasi}/etc/jitsi/jigasi/logging.properties";
126 description = "Jitsi Gateway to SIP";
127 wantedBy = [ "multi-user.target" ];
128 after = [ "network.target" ];
131 [ -f "${sipCommunicatorPropertiesFile}" ] && rm -f "${sipCommunicatorPropertiesFile}"
132 mkdir -p "$(dirname ${sipCommunicatorPropertiesFile})"
133 temp="${sipCommunicatorPropertiesFile}.unsubstituted"
135 export DOMAIN_BASE="${cfg.xmppDomain}"
136 export JIGASI_XMPP_PASSWORD=$(cat "${cfg.userPasswordFile}")
137 export JIGASI_DEFAULT_JVB_ROOM_NAME="${cfg.defaultJvbRoomName}"
139 # encode the credentials to base64
140 export JIGASI_SIPPWD=$(echo -n "$JIGASI_SIPPWD" | base64 -w 0)
141 export JIGASI_XMPP_PASSWORD_BASE64=$(cat "${cfg.userPasswordFile}" | base64 -w 0)
143 cp "${sipCommunicatorPropertiesFileUnsubstituted}" "$temp"
146 net.java.sip.communicator.impl.protocol.sip.acc1403273890647.SERVER_PORT=$JIGASI_SIPPORT
147 net.java.sip.communicator.impl.protocol.sip.acc1403273890647.PREFERRED_TRANSPORT=udp
151 # Replace <<$VAR_NAME>> from example config to $VAR_NAME for environment substitution
153 's/<<([^>]+)>>/\$\1/g' \
157 's|\(net\.java\.sip\.communicator\.impl\.protocol\.jabber\.acc-xmpp-1\.PASSWORD=\).*|\1\$JIGASI_XMPP_PASSWORD_BASE64|g' \
161 's|\(#\)\(org.jitsi.jigasi.DEFAULT_JVB_ROOM_NAME=\).*|\2\$JIGASI_DEFAULT_JVB_ROOM_NAME|g' \
164 ${pkgs.envsubst}/bin/envsubst \
165 -o "${sipCommunicatorPropertiesFile}" \
168 # Set the brewery room name
170 's|\(net\.java\.sip\.communicator\.impl\.protocol\.jabber\.acc-xmpp-1\.BREWERY=\).*|\1${cfg.bridgeMuc}|g' \
171 "${sipCommunicatorPropertiesFile}"
173 's|\(org\.jitsi\.jigasi\.ALLOWED_JID=\).*|\1${cfg.bridgeMuc}|g' \
174 "${sipCommunicatorPropertiesFile}"
177 # Disable certificate verification for self-signed certificates
179 's|\(# \)\(net.java.sip.communicator.service.gui.ALWAYS_TRUST_MODE_ENABLED=true\)|\2|g' \
180 "${sipCommunicatorPropertiesFile}"
184 config.environment.etc."jitsi/jigasi/sip-communicator.properties".source
186 environment.JAVA_SYS_PROPS = lib.concatStringsSep " " (lib.mapAttrsToList (k: v: "${k}=${toString v}") jigasiProps);
189 ${pkgs.jigasi}/bin/jigasi \
190 --host="${cfg.xmppHost}" \
191 --domain="${if cfg.xmppDomain == null then cfg.xmppHost else cfg.xmppDomain}" \
192 --secret="$(cat ${cfg.componentPasswordFile})" \
193 --user_name="${cfg.userName}" \
194 --user_domain="${cfg.userDomain}" \
195 --user_password="$(cat ${cfg.userPasswordFile})" \
196 --configdir="${stateDir}" \
197 --configdirname="${homeDirName}"
205 Group = "jitsi-meet";
207 CapabilityBoundingSet = "";
208 NoNewPrivileges = true;
209 ProtectSystem = "strict";
212 PrivateDevices = true;
213 ProtectHostname = true;
214 ProtectKernelTunables = true;
215 ProtectKernelModules = true;
216 ProtectControlGroups = true;
217 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
218 RestrictNamespaces = true;
219 LockPersonality = true;
220 RestrictRealtime = true;
221 RestrictSUIDSGID = true;
222 StateDirectory = baseNameOf stateDir;
223 EnvironmentFile = cfg.environmentFile;
227 environment.etc."jitsi/jigasi/sip-communicator.properties".source =
228 lib.mkDefault "${sipCommunicatorPropertiesFile}";
229 environment.etc."jitsi/jigasi/logging.properties".source =
230 lib.mkDefault "${stateDir}/logging.properties-journal";
233 meta.maintainers = lib.teams.jitsi.members;