Matrix: Difference between revisions
m Simplify code slightly |
Phanirithvij (talk | contribs) m fix config file url |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 28: | Line 28: | ||
A [https://search.nixos.org/packages?query=purple-matrix Pidgin / libpurple plugin] is also available. | A [https://search.nixos.org/packages?query=purple-matrix Pidgin / libpurple plugin] is also available. | ||
=== | === Web clients === | ||
==== element-web ==== | |||
There is also a web version of [https://search.nixos.org/packages?query=element-web Element] which can be served using a web server. See [https://nixos.org/nixos/manual/index.html#module-services-matrix-element-web the NixOS manual entry].<syntaxhighlight lang="nixos"> | |||
{ | |||
services.nginx.enable = true; | |||
<syntaxhighlight lang="nix"> | # See https://nixos.org/manual/nixos/stable/index.html#module-services-matrix-element-web | ||
services.nginx.virtualHosts."localhost" = { | |||
listen = [{ | |||
addr = "[::1]"; | |||
}; | port = yourPort; | ||
}]; | |||
root = pkgs.element-web.override { | |||
# See https://github.com/element-hq/element-web/blob/develop/config.sample.json | |||
conf = { | |||
default_theme = "dark"; | |||
}; | |||
}; | |||
}; | |||
} | |||
</syntaxhighlight>Alternatively, you can write a script to start the web client on demand.<syntaxhighlight lang="nix"> | |||
let | |||
# port = yourPort; | |||
web-dir = pkgs.element-web.override { | |||
conf = { | |||
default_theme = "dark"; | |||
show_labs_settings = true; | |||
}; | |||
}; | |||
element-web = pkgs.writeScriptBin "element-web" '' | |||
#!${pkgs.bash}/bin/bash | |||
set -e | |||
${pkgs.python3}/bin/python3 -m http.server ${port} -b ::1 -d ${web-dir} | |||
''; | |||
in | |||
{ | |||
home.sessionPath = [ "${element-web}/bin" ]; | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== Servers == | == Servers == | ||
=== Homeservers === | === Homeservers === | ||
==== Conduit ==== | |||
<syntaxhighlight lang="nixos"> | |||
{ | |||
# See https://search.nixos.org/options?channel=unstable&query=services.matrix-conduit. | |||
# and https://docs.conduit.rs/configuration.html | |||
services.matrix-conduit = { | |||
enable = true; | |||
settings.global = { | |||
# allow_registration = true; | |||
# server_name = yourDomainName; | |||
# port = yourPort; | |||
address = "::1"; | |||
database_backend = "rocksdb"; | |||
# See https://www.metered.ca/tools/openrelay | |||
turn_uris = [ | |||
"turn:staticauth.openrelay.metered.ca:80?transport=udp" | |||
"turn:staticauth.openrelay.metered.ca:80?transport=tcp" | |||
]; | |||
turn_secret = "openrelayprojectsecret"; | |||
}; | |||
}; | |||
} | |||
</syntaxhighlight> | |||
==== Synapse ==== | ==== Synapse ==== | ||
[https://element-hq.github.io/synapse/latest/welcome_and_overview.html Synapse] has an associated module exposing the [https://search.nixos.org/options?query=services.matrix-synapse services.matrix-synapse.* options]. See [https://nixos.org/nixos/manual/index.html#module-services-matrix-synapse the NixOS manual entry] for a complete configuration example. | |||
===== Coturn with Synapse ===== | ===== Coturn with Synapse ===== | ||
For WebRTC calls to work when both callers are behind a NAT, you need to provide a turn server for clients to use. Here is an example configuration, inspired from [https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/roles/matrix-coturn/templates/turnserver.conf.j2 this configuration file]. | For WebRTC calls to work when both callers are behind a NAT, you need to provide a turn server for clients to use. Here is an example configuration, inspired from [https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/roles/custom/matrix-coturn/templates/turnserver.conf.j2 this configuration file]. | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
Line 119: | Line 169: | ||
}; | }; | ||
# configure synapse to point users to coturn | # configure synapse to point users to coturn | ||
services.matrix-synapse = with config.services.coturn; { | services.matrix-synapse.settings = with config.services.coturn; { | ||
turn_uris = ["turn:${realm}:3478?transport=udp" "turn:${realm}:3478?transport=tcp"]; | turn_uris = ["turn:${realm}:3478?transport=udp" "turn:${realm}:3478?transport=tcp"]; | ||
turn_shared_secret = static-auth-secret; | turn_shared_secret = static-auth-secret; |