matrix: sliding sync

This commit is contained in:
Vivian 2024-07-13 23:59:59 +02:00
parent 8009002c89
commit 3a72f649d4
2 changed files with 36 additions and 9 deletions

View file

@ -5,7 +5,9 @@ let
base_url = "https://chat.meowy.tech"; base_url = "https://chat.meowy.tech";
server_name = "meowy.tech"; server_name = "meowy.tech";
}; };
"m.identity_server" = { }; "org.matrix.msc3575.proxy" = {
"url" = "https://sliding-chat.meowy.tech";
};
}; };
serverConfig."m.server" = "chat.meowy.tech:443"; serverConfig."m.server" = "chat.meowy.tech:443";
mkWellKnown = data: '' mkWellKnown = data: ''
@ -18,7 +20,8 @@ let
url = "https://git.0x76.dev/v/0x76.dev.git"; url = "https://git.0x76.dev/v/0x76.dev.git";
rev = "ecb7811560650381f41ee537b9c8493e004a108b"; rev = "ecb7811560650381f41ee537b9c8493e004a108b";
}; };
in { in
{
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions # settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave # on your system were taken. Its perfectly fine and recommended to leave
@ -27,7 +30,10 @@ in {
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "21.05"; # Did you read the comment? system.stateVersion = "21.05"; # Did you read the comment?
networking.firewall.allowedTCPPorts = [ 80 443 ]; networking.firewall.allowedTCPPorts = [
80
443
];
services = { services = {
# Generates vhosts for all hosts that have an `exposes` section # Generates vhosts for all hosts that have an `exposes` section
@ -102,10 +108,8 @@ in {
add_header Content-Type 'text/html; charset=UTF-8'; add_header Content-Type 'text/html; charset=UTF-8';
return 200 '<h1>meow</h1>'; return 200 '<h1>meow</h1>';
''; '';
"= /.well-known/matrix/client".extraConfig = "= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
mkWellKnown clientConfig; "= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
"= /.well-known/matrix/server".extraConfig =
mkWellKnown serverConfig;
}; };
}; };
"chat.meowy.tech" = { "chat.meowy.tech" = {
@ -115,6 +119,8 @@ in {
"/".extraConfig = '' "/".extraConfig = ''
return 303 https://element.chat.meowy.tech; return 303 https://element.chat.meowy.tech;
''; '';
"= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
"= /_matrix/client/unstable/org.matrix.msc3575/sync".proxyPass = "http://synapse.olympus:8009";
"/_matrix".proxyPass = "http://synapse.olympus:8008"; "/_matrix".proxyPass = "http://synapse.olympus:8008";
"/_synapse/client".proxyPass = "http://synapse.olympus:8008"; "/_synapse/client".proxyPass = "http://synapse.olympus:8008";
"/_synapse/admin" = { "/_synapse/admin" = {
@ -133,6 +139,11 @@ in {
}; };
}; };
}; };
"sliding-chat.meowy.tech" = {
enableACME = true;
forceSSL = true;
locations."/".proxyPass = "http://synapse.olympus:8009";
};
"element.chat.meowy.tech" = { "element.chat.meowy.tech" = {
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;

View file

@ -2,13 +2,17 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }: { config, pkgs, ... }:
let let
vs = config.vault-secrets.secrets; vs = config.vault-secrets.secrets;
port = 8008; port = 8008;
slidingSyncPort = 8009;
metricsPort = 9000; metricsPort = 9000;
in in
{
{
imports = [ ]; imports = [ ];
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default
@ -19,7 +23,7 @@ in
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment? system.stateVersion = "22.11"; # Did you read the comment?
networking.firewall.allowedTCPPorts = [ port metricsPort ]; networking.firewall.allowedTCPPorts = [ port metricsPort slidingSyncPort ];
vault-secrets.secrets.synapse = { vault-secrets.secrets.synapse = {
user = "matrix-synapse"; user = "matrix-synapse";
@ -38,6 +42,16 @@ in
''; '';
}; };
services.matrix-sliding-sync = {
enable = true;
createDatabase = true;
environmentFile = "${vs.synapse}/sync";
settings = {
SYNCV3_SERVER = "http://localhost:${toString port}";
SYNCV3_BINDADDR = ":${toString slidingSyncPort}";
};
};
services.matrix-synapse = { services.matrix-synapse = {
enable = true; enable = true;
withJemalloc = true; withJemalloc = true;
@ -109,3 +123,5 @@ in
}; };
}; };
} }