2019-03-02 15:03:38 +00:00
|
|
|
{ config, ... }:
|
|
|
|
let
|
|
|
|
hostName = "matrix.maralorn.de";
|
|
|
|
inherit (config.m-0) hosts;
|
2019-08-16 11:57:32 +00:00
|
|
|
inherit (import ../lib) unstable;
|
2019-07-31 21:56:52 +00:00
|
|
|
in {
|
2019-08-12 01:04:15 +00:00
|
|
|
networking.firewall.allowedTCPPorts = [ 8448 ];
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
services = {
|
|
|
|
nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts."${hostName}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
locations = {
|
|
|
|
"/" = {
|
|
|
|
proxyPass = "http://[::1]:8008";
|
|
|
|
extraConfig = ''
|
|
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
|
|
'';
|
2019-03-02 15:03:38 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2019-08-07 21:40:26 +00:00
|
|
|
};
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
# Postgres
|
|
|
|
postgresql = { enable = true; };
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
# Synapse
|
|
|
|
matrix-synapse = {
|
|
|
|
enable = true;
|
2019-08-16 11:57:32 +00:00
|
|
|
package = unstable.matrix-synapse;
|
2019-08-07 21:40:26 +00:00
|
|
|
enable_metrics = true;
|
|
|
|
server_name = "maralorn.de";
|
|
|
|
public_baseurl = "https://${hostName}";
|
|
|
|
url_preview_enabled = true;
|
|
|
|
database_type = "psycopg2";
|
|
|
|
max_upload_size = "30M";
|
|
|
|
create_local_database = false;
|
|
|
|
dynamic_thumbnails = true;
|
2019-08-12 01:04:15 +00:00
|
|
|
registration_shared_secret =
|
|
|
|
config.m-0.private.matrix_registration_secret;
|
2019-08-07 21:40:26 +00:00
|
|
|
macaroon_secret_key = config.m-0.private.macaroon_secret;
|
|
|
|
turn_uris = [ "turn:hera.m-0.eu:3478?transport=udp" ];
|
|
|
|
turn_shared_secret = config.m-0.private.turn_secret;
|
|
|
|
turn_user_lifetime = "5h";
|
|
|
|
allow_guest_access = true;
|
|
|
|
logConfig = ''
|
|
|
|
version: 1
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
formatters:
|
|
|
|
journal_fmt:
|
|
|
|
format: '%(name)s: [%(request)s] %(message)s'
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
filters:
|
|
|
|
context:
|
|
|
|
(): synapse.util.logcontext.LoggingContextFilter
|
|
|
|
request: ""
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
handlers:
|
|
|
|
journal:
|
|
|
|
class: systemd.journal.JournalHandler
|
|
|
|
formatter: journal_fmt
|
|
|
|
filters: [context]
|
|
|
|
SYSLOG_IDENTIFIER: synapse
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
disable_existing_loggers: True
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
loggers:
|
|
|
|
synapse:
|
|
|
|
level: WARN
|
|
|
|
synapse.storage.SQL:
|
|
|
|
level: WARN
|
2019-03-02 15:03:38 +00:00
|
|
|
|
2019-08-07 21:40:26 +00:00
|
|
|
root:
|
|
|
|
level: WARN
|
|
|
|
handlers: [journal]
|
|
|
|
'';
|
|
|
|
database_args = {
|
|
|
|
user = "matrix-synapse";
|
2019-08-16 11:57:32 +00:00
|
|
|
host = "/tmp";
|
2019-08-07 21:40:26 +00:00
|
|
|
database = "matrix-synapse";
|
|
|
|
cp_min = 5;
|
|
|
|
cp_max = 10;
|
|
|
|
};
|
|
|
|
report_stats = true;
|
|
|
|
tls_certificate_path = "/var/lib/acme/${hostName}/fullchain.pem";
|
|
|
|
tls_private_key_path = "/var/lib/acme/${hostName}/key.pem";
|
|
|
|
listeners = [
|
2019-08-12 01:04:15 +00:00
|
|
|
{
|
|
|
|
type = "metrics";
|
|
|
|
port = 9148;
|
|
|
|
bind_address = "127.0.0.1";
|
|
|
|
resources = [ ];
|
|
|
|
}
|
2019-08-07 21:40:26 +00:00
|
|
|
{
|
|
|
|
port = 8448;
|
|
|
|
bind_address = "::";
|
|
|
|
resources = [{
|
|
|
|
compress = false;
|
|
|
|
names = [ "federation" ];
|
|
|
|
}];
|
|
|
|
x_forwarded = false;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
port = 8008;
|
|
|
|
bind_address = "::1";
|
|
|
|
resources = [
|
2019-07-31 21:56:52 +00:00
|
|
|
{
|
2019-08-07 21:40:26 +00:00
|
|
|
compress = false;
|
|
|
|
names = [ "client" ];
|
2019-07-31 21:56:52 +00:00
|
|
|
}
|
|
|
|
{
|
2019-08-07 21:40:26 +00:00
|
|
|
compress = false;
|
|
|
|
names = [ "federation" ];
|
2019-07-31 21:56:52 +00:00
|
|
|
}
|
|
|
|
];
|
2019-08-07 21:40:26 +00:00
|
|
|
x_forwarded = true;
|
|
|
|
tls = false;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
security.acme.certs = {
|
|
|
|
"${hostName}" = {
|
|
|
|
group = "matrix-synapse";
|
|
|
|
allowKeysForGroup = true;
|
|
|
|
postRun =
|
|
|
|
"systemctl reload nginx.service; systemctl restart matrix-synapse.service";
|
2019-03-02 15:03:38 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|