1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-31 03:57:44 +00:00

feat: move away from cube host

This commit is contained in:
RGBCube 2025-02-28 00:29:52 +03:00
parent 07537d4889
commit 5125a31e7f
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M
36 changed files with 97 additions and 165 deletions

View file

@ -0,0 +1,97 @@
{ self, config, lib, ... }: let
inherit (config.networking) domain;
inherit (lib) const enabled genAttrs merge strings;
fqdn = "chat.${domain}";
port = 8002;
wellKnownResponse = data: /* nginx */ ''
${config.services.nginx.headers}
add_header Access-Control-Allow-Origin * always;
default_type application/json;
return 200 '${strings.toJSON data}';
'';
configWellKnownResponse.locations = {
"= /.well-known/matrix/client".extraConfig = wellKnownResponse {
"m.homeserver".base_url = "https://${fqdn}";
};
"= /.well-known/matrix/server".extraConfig = wellKnownResponse {
"m.server" = "${fqdn}:443";
};
};
in {
imports = [
(self + /modules/nginx.nix)
(self + /modules/postgresql.nix)
];
secrets.matrixSecret = {
file = ./password.secret.age;
owner = "matrix-synapse";
};
services.postgresql.ensure = [ "matrix-synapse" ];
services.restic.backups = genAttrs config.services.restic.hosts <| const {
paths = [ "/var/lib/matrix-synapse" ];
};
services.matrix-synapse = enabled {
withJemalloc = true;
configureRedisLocally = true;
settings.redis.enabled = true;
extras = [ "postgres" "url-preview" "user-search" ];
log.root.level = "WARNING"; # Shut the fuck up.
settings = {
server_name = domain;
# We are not setting web_client_location since the root is not accessible
# from the outside web at all. Only /_matrix is reverse proxied to.
database.name = "psycopg2";
report_stats = false;
enable_metrics = true;
metrics_flags.known_servers = true;
expire_access_token = true;
url_preview_enabled = true;
# Trusting Matrix.org.
suppress_key_server_warning = true;
};
# Sets registration_shared_secret.
extraConfigFiles = [ config.secrets.matrixSecret.path ];
settings.listeners = [{
inherit port;
bind_addresses = [ "::1" ];
tls = false;
type = "http";
x_forwarded = true;
resources = [{
compress = false;
names = [ "client" "federation" ];
}];
}];
};
services.nginx.virtualHosts.${domain} = configWellKnownResponse;
services.nginx.virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate configWellKnownResponse {
locations."/".return = "301 https://${domain}/404";
locations."/_matrix".proxyPass = "http://[::1]:${toString port}";
locations."/_synapse/client".proxyPass = "http://[::1]:${toString port}";
};
}

Binary file not shown.