nix-conf/systems/hetzner/matrix.nix

123 lines
3.1 KiB
Nix
Raw Normal View History

2024-07-10 23:02:54 +02:00
{ config, pkgs, ... }:
2024-04-23 19:05:54 +02:00
let
fqdn = "matrix.missing.ninja";
baseUrl = "https://${fqdn}";
clientConfig."m.homeserver".base_url = baseUrl;
serverConfig."m.server" = "${fqdn}:443";
mkWellKnown = data: ''
default_type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON data}';
'';
in
{
services.postgresql.enable = true;
services.postgresql.initialScript = pkgs.writeText "synapse-init.sql" ''
CREATE ROLE "matrix-synapse" WITH LOGIN PASSWORD 'synapse';
CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
TEMPLATE template0
LC_COLLATE = "C"
LC_CTYPE = "C";
'';
services.nginx = {
virtualHosts = {
"missing.ninja" = {
locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
};
"matrix.missing.ninja" = {
enableACME = true;
forceSSL = true;
locations."/".extraConfig = ''
return 404;
'';
2024-04-23 21:27:31 +02:00
locations."/_matrix".proxyPass = "http://[::1]:8448";
locations."/_synapse/client".proxyPass = "http://[::1]:8448";
2024-04-23 19:05:54 +02:00
};
2024-04-23 20:37:29 +02:00
"element.missing.ninja" = {
2024-04-23 19:26:40 +02:00
enableACME = true;
forceSSL = true;
root = pkgs.element-web.override {
conf = {
default_server_config = clientConfig;
};
};
};
2024-04-23 19:05:54 +02:00
};
};
services.matrix-synapse = {
enable = true;
2024-04-23 19:29:01 +02:00
settings = {
server_name = "missing.ninja";
2024-04-23 20:50:04 +02:00
registration_shared_secret = "";
2024-04-23 19:29:01 +02:00
public_baseurl = baseUrl;
2024-07-10 23:02:54 +02:00
app_service_config_files = [ "/var/lib/matrix-synapse/whatsapp-registration.yaml" ];
2024-04-23 19:29:01 +02:00
listeners = [
{
2024-04-23 21:27:31 +02:00
port = 8448;
2024-04-23 19:29:01 +02:00
bind_addresses = [ "::1" ];
type = "http";
tls = false;
x_forwarded = true;
resources = [
{
2024-07-10 23:02:54 +02:00
names = [
"client"
"federation"
];
2024-04-23 19:29:01 +02:00
compress = true;
}
];
}
];
};
2024-04-23 19:05:54 +02:00
};
2024-04-23 21:23:54 +02:00
services.mautrix-whatsapp = {
enable = true;
2024-04-23 21:36:07 +02:00
settings = {
appservice = {
database = {
2024-04-23 21:43:33 +02:00
type = "sqlite3";
uri = "/var/lib/mautrix-whatsapp/mautrix-whatsapp.db";
2024-04-23 21:36:07 +02:00
};
2024-04-23 22:01:21 +02:00
ephemeral_events = true;
2024-04-23 21:36:07 +02:00
id = "whatsapp";
};
bridge = {
encryption = {
allow = true;
default = true;
2024-04-23 22:07:23 +02:00
require = false;
2024-04-23 22:01:21 +02:00
appservice = true;
2024-04-23 21:36:07 +02:00
};
history_sync = {
request_full_sync = true;
2024-04-23 22:01:21 +02:00
message_count = -1;
2024-04-23 21:36:07 +02:00
};
mute_bridging = true;
2024-04-23 22:01:21 +02:00
personal_filtering_spaces = true;
2024-04-23 21:36:07 +02:00
permissions = {
2024-04-23 22:01:21 +02:00
"*" = "relay";
2024-04-23 21:36:07 +02:00
"missing.ninja" = "user";
2024-04-23 22:01:21 +02:00
"@admin:missing.ninja" = "admin";
2024-04-23 21:36:07 +02:00
};
private_chat_portal_meta = true;
2024-04-23 22:01:21 +02:00
whatsapp_thumbnail = true;
federate_rooms = false;
caption_in_message = true;
extev_polls = true;
cross_room_replies = true;
2024-04-23 21:36:07 +02:00
provisioning = {
shared_secret = "disable";
};
};
};
2024-04-23 21:23:54 +02:00
};
2024-04-23 19:05:54 +02:00
}