Matrix: Difference between revisions
m Minor spelling mistake |
Add section about synapse admin |
||
| (4 intermediate revisions by 3 users not shown) | |||
| Line 162: | Line 162: | ||
turn_user_lifetime = "1h"; | turn_user_lifetime = "1h"; | ||
}; | }; | ||
} | |||
</syntaxhighlight> | |||
==== Livekit ==== | |||
In order to set up element call or for calls to work in Element X it is necessary to set up and announce livekit. To set up livekit for matrix in nixos use<syntaxhighlight lang="nix" line="1"> | |||
{ config, lib, pkgs, ... }: let | |||
keyFile = "/run/livekit.key"; | |||
in { | |||
services.livekit = { | |||
enable = true; | |||
openFirewall = true; | |||
settings.room.auto_create = false; | |||
inherit keyFile; | |||
}; | |||
services.lk-jwt-service = { | |||
enable = true; | |||
# can be on the same virtualHost as synapse | |||
livekitUrl = "wss://domain.tld/livekit/sfu"; | |||
inherit keyFile; | |||
}; | |||
# generate the key when needed | |||
systemd.services.livekit-key = { | |||
before = [ "lk-jwt-service.service" "livekit.service" ]; | |||
wantedBy = [ "multi-user.target" ]; | |||
path = with pkgs; [ livekit coreutils gawk ]; | |||
script = '' | |||
echo "Key missing, generating key" | |||
echo "lk-jwt-service: $(livekit-server generate-keys | tail -1 | awk '{print $3}')" > "${keyFile}" | |||
''; | |||
serviceConfig.Type = "oneshot"; | |||
unitConfig.ConditionPathExists = "!${keyFile}"; | |||
}; | |||
# restrict access to livekit room creation to a homeserver | |||
systemd.services.lk-jwt-service.environment.LIVEKIT_FULL_ACCESS_HOMESERVERS = "domain.tld"; | |||
services.nginx.virtualHosts."domain.tld".locations = { | |||
"^~ /livekit/jwt/" = { | |||
priority = 400; | |||
proxyPass = "http://[::1]:${toString config.services.lk-jwt-service.port}/"; | |||
}; | |||
"^~ /livekit/sfu/" = { | |||
extraConfig = '' | |||
proxy_send_timeout 120; | |||
proxy_read_timeout 120; | |||
proxy_buffering off; | |||
proxy_set_header Accept-Encoding gzip; | |||
proxy_set_header Upgrade $http_upgrade; | |||
proxy_set_header Connection "upgrade"; | |||
''; | |||
priority = 400; | |||
proxyPass = "http://[::1]:${toString config.services.livekit.settings.port}/"; | |||
proxyWebsockets = true; | |||
}; | |||
}; | |||
} | |||
</syntaxhighlight>Furthermore, it is necessary to announce the service with a <code>domain.tld/.well-known/matrix/client</code> which needs to be served as <code>Content-Type application/json</code> (calls in Element X might not work without the content-type) and contain<syntaxhighlight lang="json"> | |||
{ | |||
"m.homeserver": { | |||
"base_url": "https://domain.tld" | |||
}, | |||
"m.identity_server": { | |||
"base_url": "https://vector.im" | |||
}, | |||
"org.matrix.msc3575.proxy": { | |||
"url": "https://domain.tld" | |||
}, | |||
"org.matrix.msc4143.rtc_foci": [ | |||
{ | |||
"type": "livekit", "livekit_service_url": "https://domain.tld/livekit/jwt" | |||
} | |||
] | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 168: | Line 239: | ||
There's an external module to automatically set up synapse and configure nginx with workers: | There's an external module to automatically set up synapse and configure nginx with workers: | ||
https://github.com/dali99/nixos-matrix-modules | https://github.com/dali99/nixos-matrix-modules | ||
==== Synapse Admin with Caddy ==== | |||
Setting up [https://github.com/etkecc/synapse-admin Synapse Admin] with [[Caddy]] is quite easy! | |||
The example uses the newer <code>pkgs.synapse-admin-etkecc</code> which may not be what you want if you have heard of the old one which is available at: <code>pkgs.synapse-admin</code> | |||
{{File|3={ pkgs, ... }: | |||
let | |||
synapse-admin = pkgs.synapse-admin-etkecc.withConfig { | |||
restrictBaseUrl = [ | |||
"https://matrix.example.com" # Synapse domain | |||
]; | |||
}; | |||
in | |||
{ | |||
services.caddy.virtualHosts."synapse-admin.example.com".extraConfig = '' | |||
root * ${synapse-admin} | |||
file_server | |||
''; | |||
}|name=/etc/nixos/configuration.nix|lang=nix}} | |||
== Application services (a.k.a. bridges) == | == Application services (a.k.a. bridges) == | ||
| Line 254: | Line 344: | ||
=== mautrix-whatsapp === | === mautrix-whatsapp === | ||
Packaged as [https://search.nixos.org/packages?query=mautrix-whatsapp mautrix-whatsapp]. | Packaged as [https://search.nixos.org/packages?query=mautrix-whatsapp mautrix-whatsapp]. | ||
=== matrix-appservice-irc === | === matrix-appservice-irc === | ||