✨ darkone.service.matrix
DNF matrix (synapse) homeserver.
Sub-modules (matrix/):
mas.nix: authentication, delegated to Matrix Authentication Service;bridges.nix: mautrix bridges, usable by every local account;rtc.nix: MatrixRTC backend (LiveKit) for Element Call.
Federation
Section titled “Federation”Federation is configurable via darkone.service.matrix.federation:
enable = false: blocks all federation (empty domain whitelist).enable = true; whitelist = [ ]: open federation with every server.enable = true; whitelist = [ "ami.org" ]: allowlist (inbound + outbound).
Discovery stays locked regardless (rooms absent from remote directories, profiles private over federation), so the network is reachable but not searchable.
Friend self-registration (friendRegistration.enable) opens token-gated
local password accounts alongside Kanidm OIDC users. Mint a token on the host
with sudo dnf-mas manage issue-user-registration-token.
Administrators
Section titled “Administrators”network.matrix.admins (local parts) is the single declarative source for
both administrations, applied at rebuild with no database write:
- bridges:
adminlevel in every mautrixpermissionsmap; - server:
policy.data.admin_users, which the bundled MAS policy turns into theurn:mas:adminandurn:synapse:admin:*scopes (MAS admin API, synapse admin API,matrix-adminUI login).
Authentication (mas.nix)
Section titled “Authentication (mas.nix)”All authentication goes through Matrix Authentication Service, always:
Element X, QR login and the /account self-service portal only exist there,
and synapse’s own auth is deprecated upstream (MSC3861). Kanidm stays the
identity source: MAS is the OIDC client instead of synapse, and synapse only
asks MAS to introspect tokens.
Same vhost: MAS owns the root + compat auth endpoints, synapse keeps
/_matrix/* and /_synapse/*. Client discovery is automatic (synapse
serves auth_metadata itself), no well-known change.
Required sops secrets, all created by just configure-admin-host:
mas-encryption-secret, mas-synapse-secret and mas-rsa-private-key.
dnf-mas (root) wraps mas-cli for host-side administration: registration
tokens, promote-admin, register-user, syn2mas. MAS runs with
DynamicUser and reads its secrets from systemd credentials, absent outside
the running unit; the wrapper rebuilds an equivalent credentials directory
from the sops files, so it works whether the service is up or down (syn2mas
needs it down).
mas-cli only acts, never lists: enable the matrix-admin service for the
read side (accounts, devices, sessions), it speaks both admin APIs.
Bridges (bridges.nix)
Section titled “Bridges (bridges.nix)”mautrix bridges: WhatsApp, Signal, Telegram, Messenger, Discord. Each user
links their own remote account by talking to the bridge bot
(@whatsappbot, @signalbot, … then login); sessions are isolated per
user. Bridge administrators: cf. “Administrators” above.
Double puppeting: official appservice method
(https://docs.mau.fi/bridges/general/double-puppeting.html 🡕). A shared
doublepuppet appservice token lets bridges send remote-originated messages
as the user’s real matrix account. Required sops secrets:
mautrix-doublepuppet-as-token and mautrix-doublepuppet-hs-token
(generated by just configure-admin-host).
Every bridge’s appservice as/hs tokens are sops-provided, never auto-generated: the registration file is a pure function of the secrets, so resetting a bridge’s state dir never invalidates the registration synapse loaded (“as_token was not accepted”, registration wipe + synapse restart).
Calls (rtc.nix)
Section titled “Calls (rtc.nix)”Two stacks coexist, because no single one covers every client:
- Legacy 1:1 WebRTC, negotiated over synapse and relayed by coturn
(
darkone.service.turn). The only thing Element Classic speaks. - MatrixRTC (
matrixRtc.enable): a LiveKit SFU plus its authorization service, for group calls and for Element Call. Element X speaks only this one and reports “call is not supported” (MISSING_MATRIX_RTC_TRANSPORT) without it; Element Web/Desktop embed Element Call too and gain group calls from it.
Both are served from the matrix vhost, next to synapse and MAS: the SFU
websocket on /livekit/sfu, the JWT service on /livekit/jwt. Clients
discover it from matrix_rtc.transports (synapse, MSC4143) and, as a
fallback for older ones, from rtc_foci in the well-known.
Required sops secret: livekit-secret (just configure-admin-host),
shared by the SFU and the JWT service.
Options
Section titled “Options”- enable
boolEnable matrix (synapse) service - federation.enable
boolAllow server-to-server federation. False blocks all federation. - federation.whitelist
listOf strEmpty = federate with all servers; non-empty = only these domains (inbound + outbound). - matrixRtc.enable
boolEnable the MatrixRTC backend (LiveKit SFU) for Element Call group calls. - friendRegistration.enable
boolAllow friends to self-register with an invite token (token-gated). - bridges.whatsapp.enable
boolMautrix WhatsApp bridge (login by QR code). - bridges.signal.enable
boolMautrix Signal bridge (login by QR code). - bridges.telegram.enable
boolMautrix Telegram bridge (login by phone number). - bridges.messenger.enable
boolMautrix Facebook Messenger bridge (login by cookies). - bridges.discord.enable
boolMautrix Discord bridge (login by QR code, experimental). - shared
rawMatrix values shared with thematrix/sub-modules.
darkone.service.matrix = { enable = false; federation.enable = false; federation.whitelist = [ ]; matrixRtc.enable = false; friendRegistration.enable = false; bridges.whatsapp.enable = true; bridges.signal.enable = true; bridges.telegram.enable = true; bridges.messenger.enable = true; bridges.discord.enable = false; shared = { inherit params masKanidmUlid livekitJwtUrl matrixAdmins ; };};Source: modules/service/matrix.nix 🡕