Revert "Merge pull request 'clanModules: Init nginx module. matrix-synapse: don't assume domain names' (#1906) from Qubasa/clan-core:Qubasa-new-main into main"

This reverts commit b29f649343, reversing
changes made to 9c8be387fa.

Apparently this breaks assumptions about matrix: https://git.clan.lol/clan/clan-core/pulls/1906#issuecomment-13184
This commit is contained in:
Jörg Thalheim
2024-08-21 10:03:13 +02:00
parent 4a06ea9391
commit 2fc4bccfd5
9 changed files with 27 additions and 278 deletions

View File

@@ -6,31 +6,25 @@
}:
let
cfg = config.clan.matrix-synapse;
nginx-vhost = "matrix.${config.clan.matrix-synapse.domain}";
element-web =
pkgs.runCommand "element-web-with-config" { nativeBuildInputs = [ pkgs.buildPackages.jq ]; }
''
cp -r ${pkgs.element-web} $out
chmod -R u+w $out
jq '."default_server_config"."m.homeserver" = { "base_url": "https://${cfg.domain.server}:443", "server_name": "${cfg.domain.server}" }' \
jq '."default_server_config"."m.homeserver" = { "base_url": "https://${nginx-vhost}:443", "server_name": "${config.clan.matrix-synapse.domain}" }' \
> $out/config.json < ${pkgs.element-web}/config.json
ln -s $out/config.json $out/config.${cfg.domain.server}.json
ln -s $out/config.json $out/config.${nginx-vhost}.json
'';
in
# FIXME: This was taken from upstream. Drop this when our patch is upstream
{
options.services.matrix-synapse.package = lib.mkOption { readOnly = false; };
options.clan.matrix-synapse = {
domain = {
server = lib.mkOption {
type = lib.types.str;
description = "The domain name of the matrix server";
example = "matrix.example.com";
};
client = lib.mkOption {
type = lib.types.str;
description = "The domain name of the matrix client";
example = "element.example.com";
};
domain = lib.mkOption {
type = lib.types.str;
description = "The domain name of the matrix server";
example = "example.com";
};
users = lib.mkOption {
default = { };
@@ -67,14 +61,14 @@ in
"matrix-synapse"
"enable"
] "Importing the module will already enable the service.")
../nginx
../postgresql
];
config = {
services.matrix-synapse = {
enable = true;
settings = {
server_name = cfg.domain.server;
enable_registration = false;
server_name = cfg.domain;
database = {
args.user = "matrix-synapse";
args.database = "matrix-synapse";
@@ -175,13 +169,18 @@ in
];
};
networking.firewall.allowedTCPPorts = [
80
443
];
services.nginx = {
enable = true;
virtualHosts = {
"${cfg.domain.server}" = {
${cfg.domain} = {
locations."= /.well-known/matrix/server".extraConfig = ''
add_header Content-Type application/json;
return 200 '${builtins.toJSON { "m.server" = "${cfg.domain.server}:443"; }}';
return 200 '${builtins.toJSON { "m.server" = "matrix.${cfg.domain}:443"; }}';
'';
locations."= /.well-known/matrix/client".extraConfig = ''
add_header Content-Type application/json;
@@ -189,7 +188,7 @@ in
return 200 '${
builtins.toJSON {
"m.homeserver" = {
"base_url" = "https://${cfg.domain.server}";
"base_url" = "https://${nginx-vhost}";
};
"m.identity_server" = {
"base_url" = "https://vector.im";
@@ -197,14 +196,12 @@ in
}
}';
'';
};
${nginx-vhost} = {
forceSSL = true;
enableACME = true;
locations."/_matrix".proxyPass = "http://localhost:8008";
locations."/_synapse".proxyPass = "http://localhost:8008";
};
"${cfg.domain.client}" = {
forceSSL = true;
enableACME = true;
locations."/".root = element-web;
};
};