116 lines
3.2 KiB
Nix
116 lines
3.2 KiB
Nix
{ pkgs, config, ... }:
|
|
|
|
with import ./network.nix;
|
|
{
|
|
services = {
|
|
matrix-synapse = {
|
|
enable = true;
|
|
server_name = "${matrixdomain}";
|
|
database_type = "sqlite3";
|
|
public_baseurl = "https://${matrixdomain}";
|
|
registration_shared_secret = "runas!";
|
|
dynamic_thumbnails = true;
|
|
enable_registration = true;
|
|
app_service_config_files = [ "/var/lib/matrix-synapse/discord-registration.yaml" ];
|
|
extraConfig = ''
|
|
auto_join_rooms:
|
|
- "#infra:matrix.giugl.io"
|
|
- "#general:matrix.giugl.io"
|
|
- "#gaming:matrix.giugl.io"
|
|
- "#movies:matrix.giugl.io"
|
|
'';
|
|
listeners = [
|
|
{
|
|
port = 8008;
|
|
bind_address = "::1";
|
|
type = "http";
|
|
tls = false;
|
|
x_forwarded = true;
|
|
resources = [
|
|
{
|
|
names = [ "client" "federation" ];
|
|
compress = false;
|
|
}
|
|
];
|
|
}
|
|
];
|
|
};
|
|
|
|
nginx.virtualHosts = {
|
|
# server
|
|
${matrixdomain} = {
|
|
enableACME = true;
|
|
forceSSL = true;
|
|
locations."= /.well-known/matrix/server".extraConfig =
|
|
let
|
|
server = { "m.server" = "${matrixdomain}:443"; };
|
|
in ''
|
|
add_header Content-Type application/json;
|
|
return 200 '${builtins.toJSON server}';
|
|
'';
|
|
|
|
locations."= /.well-known/matrix/client".extraConfig =
|
|
let
|
|
client = {
|
|
"m.homeserver" = { "base_url" = "https://${matrixdomain}:443"; };
|
|
"m.identity_server" = { "base_url" = "https://vector.im"; };
|
|
};
|
|
# ACAO required to allow element-web on any URL to request this json file
|
|
in ''
|
|
add_header Content-Type application/json;
|
|
add_header Access-Control-Allow-Origin *;
|
|
return 200 '${builtins.toJSON client}';
|
|
'';
|
|
|
|
|
|
locations."/".extraConfig = ''
|
|
return 404;
|
|
'';
|
|
|
|
# forward all Matrix API calls to the synapse Matrix homeserver
|
|
locations."/_matrix" = {
|
|
proxyPass = "http://[::1]:8008"; # without a trailing /
|
|
};
|
|
};
|
|
|
|
# web client
|
|
|
|
"${matrixwebdomain}" = {
|
|
enableACME = true;
|
|
forceSSL = true;
|
|
|
|
root = pkgs.element-web.override {
|
|
conf = {
|
|
default_server_config."m.homeserver" = {
|
|
"base_url" = "https://${matrixdomain}";
|
|
"server_name" = "${matrixdomain}";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
matrix-appservice-discord = {
|
|
enable = true;
|
|
environmentFile = /secrets/matrix-appservice-discord/tokens.env;
|
|
# The appservice is pre-configured to use SQLite by default.
|
|
# It's also possible to use PostgreSQL.
|
|
settings = {
|
|
bridge = {
|
|
domain = matrixdomain;
|
|
homeserverUrl = "https://${matrixdomain}";
|
|
disablePresence = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
networking.extraHosts = ''
|
|
127.0.0.1 ${matrixdomain} ${matrixwebdomain}
|
|
${architect-lan} ${matrixdomain} ${matrixwebdomain}
|
|
${architect-wg} ${matrixdomain} ${matrixwebdomain}
|
|
'';
|
|
|
|
users.groups.acme.members = [ "turnserver" ];
|
|
}
|