2024-05-08 20:57:07 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}:
|
2023-10-29 03:48:26 +00:00
|
|
|
let
|
|
|
|
commonHeaders = ''
|
|
|
|
add_header Permissions-Policy interest-cohort=() always;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
|
|
add_header X-XSS-Protection "1; mode=block";
|
|
|
|
'';
|
2024-04-28 15:25:40 +00:00
|
|
|
clientConfig = import ./element-client-config.nix { inherit lib pkgs; };
|
2023-11-16 19:10:39 +00:00
|
|
|
wellKnownClient = domain: {
|
|
|
|
"m.homeserver".base_url = "https://matrix.${domain}";
|
|
|
|
"m.identity_server".base_url = "https://matrix.${domain}";
|
2023-12-16 13:57:36 +00:00
|
|
|
"org.matrix.msc3575.proxy".url = "https://matrix.${domain}";
|
2023-11-07 14:19:55 +00:00
|
|
|
"im.vector.riot.e2ee".default = true;
|
|
|
|
"io.element.e2ee" = {
|
|
|
|
default = true;
|
|
|
|
secure_backup_required = false;
|
|
|
|
secure_backup_setup_methods = [ ];
|
|
|
|
};
|
|
|
|
"m.integrations" = {
|
|
|
|
managers = [
|
|
|
|
{
|
2023-11-16 19:10:39 +00:00
|
|
|
api_url = "https://dimension.${domain}/api/v1/scalar";
|
|
|
|
ui_url = "https://dimension.${domain}/element";
|
2023-11-07 14:19:55 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-11-18 16:34:33 +00:00
|
|
|
wellKnownServer = domain: { "m.server" = "matrix.${domain}:8448"; };
|
2023-11-25 13:25:46 +00:00
|
|
|
wellKnownSupport = {
|
|
|
|
contacts = [
|
|
|
|
{
|
|
|
|
email_address = "crew@pub.solar";
|
|
|
|
matrix_id = "@b12f:pub.solar";
|
|
|
|
role = "m.role.admin";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
email_address = "crew@pub.solar";
|
|
|
|
matrix_id = "@hensoko:pub.solar";
|
|
|
|
role = "m.role.admin";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
email_address = "crew@pub.solar";
|
|
|
|
matrix_id = "@teutat3s:pub.solar";
|
|
|
|
role = "m.role.admin";
|
|
|
|
}
|
|
|
|
];
|
2024-05-08 17:47:47 +00:00
|
|
|
support_page = "https://${config.pub-solar-os.networking.domain}/about";
|
2023-11-25 13:25:46 +00:00
|
|
|
};
|
2023-10-29 03:48:26 +00:00
|
|
|
mkWellKnown = data: ''
|
|
|
|
add_header Content-Type application/json;
|
|
|
|
add_header Access-Control-Allow-Origin *;
|
|
|
|
return 200 '${builtins.toJSON data}';
|
|
|
|
'';
|
2023-11-16 19:10:39 +00:00
|
|
|
wellKnownLocations = domain: {
|
|
|
|
"= /.well-known/matrix/server".extraConfig = mkWellKnown (wellKnownServer domain);
|
|
|
|
"= /.well-known/matrix/client".extraConfig = mkWellKnown (wellKnownClient domain);
|
2023-11-25 13:25:46 +00:00
|
|
|
"= /.well-known/matrix/support".extraConfig = mkWellKnown wellKnownSupport;
|
2023-10-29 03:48:26 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
services.nginx.virtualHosts = {
|
2023-11-07 14:19:55 +00:00
|
|
|
|
|
|
|
#####################################
|
|
|
|
# This is already in production use #
|
|
|
|
#####################################
|
|
|
|
|
2024-05-08 17:47:47 +00:00
|
|
|
"${config.pub-solar-os.networking.domain}" = {
|
|
|
|
locations = wellKnownLocations "${config.pub-solar-os.networking.domain}";
|
2023-10-29 03:48:26 +00:00
|
|
|
};
|
|
|
|
|
2024-05-08 17:47:47 +00:00
|
|
|
"chat.${config.pub-solar-os.networking.domain}" = {
|
2023-10-29 03:48:26 +00:00
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
2024-05-08 20:57:07 +00:00
|
|
|
root = pkgs.element-web.override { conf = clientConfig; };
|
2023-10-29 03:48:26 +00:00
|
|
|
};
|
|
|
|
|
2024-05-08 17:47:47 +00:00
|
|
|
"stickers.chat.${config.pub-solar-os.networking.domain}" = {
|
2024-04-29 22:52:07 +00:00
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
root = pkgs.element-stickerpicker;
|
|
|
|
};
|
|
|
|
|
2024-05-08 17:47:47 +00:00
|
|
|
"matrix.${config.pub-solar-os.networking.domain}" = {
|
2023-10-29 03:48:26 +00:00
|
|
|
root = "/dev/null";
|
|
|
|
|
|
|
|
forceSSL = lib.mkDefault true;
|
|
|
|
enableACME = lib.mkDefault true;
|
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
server_tokens off;
|
|
|
|
gzip on;
|
|
|
|
gzip_types text/plain application/json;
|
|
|
|
'';
|
2023-11-18 16:34:33 +00:00
|
|
|
locations = {
|
2023-11-19 14:47:25 +00:00
|
|
|
# For telegram
|
2023-10-29 03:48:26 +00:00
|
|
|
"/c3c3f34b-29fb-5feb-86e5-98c75ec8214b" = {
|
|
|
|
proxyPass = "http://127.0.0.1:8009";
|
|
|
|
extraConfig = commonHeaders;
|
|
|
|
};
|
|
|
|
|
2023-12-16 12:53:34 +00:00
|
|
|
# sliding-sync
|
2023-12-16 13:48:08 +00:00
|
|
|
"~ ^/(client/|_matrix/client/unstable/org.matrix.msc3575/sync)" = {
|
2023-12-16 12:53:34 +00:00
|
|
|
proxyPass = "http://127.0.0.1:8011";
|
|
|
|
extraConfig = commonHeaders;
|
|
|
|
};
|
|
|
|
|
2023-10-29 03:48:26 +00:00
|
|
|
"~* ^(/_matrix|/_synapse/client|/_synapse/oidc)" = {
|
|
|
|
proxyPass = "http://127.0.0.1:8008";
|
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
${commonHeaders}
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
|
|
|
|
|
|
|
client_body_buffer_size 25M;
|
|
|
|
client_max_body_size 50M;
|
|
|
|
proxy_max_temp_file_size 0;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-05-08 17:47:47 +00:00
|
|
|
"matrix.${config.pub-solar-os.networking.domain}-federation" = {
|
|
|
|
serverName = "matrix.${config.pub-solar-os.networking.domain}";
|
2023-10-29 03:48:26 +00:00
|
|
|
forceSSL = lib.mkDefault true;
|
|
|
|
enableACME = lib.mkDefault true;
|
2024-05-08 20:57:07 +00:00
|
|
|
listen = [
|
|
|
|
{
|
|
|
|
port = 8448;
|
|
|
|
addr = "0.0.0.0";
|
|
|
|
ssl = true;
|
|
|
|
}
|
2023-10-29 03:48:26 +00:00
|
|
|
{
|
|
|
|
port = 8448;
|
|
|
|
addr = "[::]";
|
|
|
|
ssl = true;
|
2024-05-08 20:57:07 +00:00
|
|
|
}
|
|
|
|
];
|
2023-10-29 03:48:26 +00:00
|
|
|
root = "/dev/null";
|
|
|
|
extraConfig = ''
|
|
|
|
server_tokens off;
|
|
|
|
|
|
|
|
gzip on;
|
|
|
|
gzip_types text/plain application/json;
|
|
|
|
'';
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://127.0.0.1:8008";
|
|
|
|
extraConfig = ''
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
|
|
|
|
|
|
|
client_body_buffer_size 25M;
|
|
|
|
client_max_body_size 150M;
|
|
|
|
proxy_max_temp_file_size 0;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
networking.firewall.allowedTCPPorts = [ 8448 ];
|
|
|
|
}
|