push
This commit is contained in:
1 parent
c86ee98def
commit
a3163cdd43
29 files changed
+693
-231
No files matched your search
+15
-49
@@ -1,44 +1,27 @@
|
||||
{
|
||||
den.aspects.services.matrix = {
|
||||
nixos = {
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
host,
|
||||
...
|
||||
}: let
|
||||
port = 8008;
|
||||
den.aspects.services.matrix = let port = 8008; in {
|
||||
tunnel = { subdomain = "matrix"; inherit port; };
|
||||
|
||||
nixos = { lib, host, ... }: let
|
||||
inherit (host) domain;
|
||||
matrixDomain = "matrix.${domain}";
|
||||
clientConfig = {
|
||||
"m.homeserver".base_url = "https://${matrixDomain}";
|
||||
"m.identity_server" = {};
|
||||
};
|
||||
serverConfig = {
|
||||
"m.server" = "${matrixDomain}:443";
|
||||
};
|
||||
mkWellKnown = data: ''
|
||||
default_type application/json;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
return 200 '${builtins.toJSON data}';
|
||||
'';
|
||||
secret = "/var/lib/matrix-synapse/registration_secret";
|
||||
in {
|
||||
services.matrix-synapse = {
|
||||
enable = true;
|
||||
settings = {
|
||||
server_name = domain;
|
||||
public_baseurl = "https://${matrixDomain}";
|
||||
public_baseurl = "https://matrix.${domain}";
|
||||
|
||||
listeners = [
|
||||
{
|
||||
port = port;
|
||||
bind_addresses = ["127.0.0.1"];
|
||||
inherit port;
|
||||
bind_addresses = [ "127.0.0.1" ];
|
||||
type = "http";
|
||||
tls = false;
|
||||
x_forwarded = true;
|
||||
resources = [
|
||||
{
|
||||
names = ["client" "federation"];
|
||||
names = [ "client" "federation" ];
|
||||
compress = true;
|
||||
}
|
||||
];
|
||||
@@ -59,7 +42,7 @@
|
||||
url_preview_enabled = true;
|
||||
enable_registration = false;
|
||||
enable_metrics = false;
|
||||
registration_shared_secret_path = "/var/lib/matrix-synapse/registration_secret";
|
||||
registration_shared_secret_path = secret;
|
||||
|
||||
trusted_key_servers = [
|
||||
{
|
||||
@@ -69,9 +52,13 @@
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.matrix-synapse.preStart = lib.mkBefore ''
|
||||
[ -s ${secret} ] || (umask 077; head -c 32 /dev/urandom | base64 | tr -d '\n' > ${secret})
|
||||
'';
|
||||
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
ensureDatabases = ["matrix-synapse"];
|
||||
ensureDatabases = [ "matrix-synapse" ];
|
||||
ensureUsers = [
|
||||
{
|
||||
name = "matrix-synapse";
|
||||
@@ -79,27 +66,6 @@
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts.${domain} = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
|
||||
locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts.${matrixDomain} = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString port}";
|
||||
extraConfig = ''
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $host;
|
||||
client_max_body_size 100M;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user