nix-config/hosts/matrix/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

128 lines
3.3 KiB
Nix
Raw Permalink Normal View History

2024-03-14 19:03:05 +01:00
{ config, libC, pkgs, ... }:
2023-03-24 01:56:38 +01:00
{
c3d2.deployment.server = "server10";
microvm = {
2023-09-15 22:42:24 +02:00
mem = 1536;
2023-03-24 01:56:38 +01:00
vcpu = 2;
};
networking.hostName = "matrix";
2023-05-29 21:44:35 +02:00
nixpkgs.overlays = [
(final: prev: {
2023-12-09 23:31:22 +01:00
matrix-synapse = prev.matrix-synapse.overrideAttrs (_: {
2023-05-29 21:44:35 +02:00
# fail and take a good amount of time
doCheck = false;
});
})
];
2023-03-24 01:56:38 +01:00
services = {
2023-11-11 04:27:22 +01:00
backup = {
enable = true;
paths = [ "/var/lib/matrix-synapse/" ];
};
2023-05-18 17:15:18 +02:00
2023-03-24 01:56:38 +01:00
matrix-synapse = {
enable = true;
2023-03-25 16:05:30 +01:00
element-web = {
enable = true;
domain = "element.c3d2.de";
};
2023-03-24 01:56:38 +01:00
extraConfigFiles = [
config.sops.secrets."matrix-synapse/config".path
];
ldap = {
enable = true;
2024-03-14 19:45:25 +01:00
searchUserPasswordFile = config.sops.secrets."matrix-synapse/ldapSearchUserPassword".path;
2023-03-24 01:56:38 +01:00
};
settings = {
admin_contact = "mailto:mail@c3d2.de";
email = {
enable_notifs = true;
notif_for_new_users = false;
notif_from = "Your Friendly %(app)s homeserver <matrix@c3d2.de>";
require_transport_security = true;
smtp_host = "mail.c3d2.de";
smtp_user = "matrix@c3d2.de";
};
enable_registration = false;
# duplicated in extraConfigFile since synapse is not deep merging the files
# password_config = {
# policy = {
# enabled = true;
# require_digit = true;
# require_lowercase = true;
# require_symbol = true;
# require_uppercase = true;
# };
# };
public_baseurl = "https://matrix.c3d2.de/";
registration_requires_token = true;
report_stats = false;
retention = {
enabled = true;
default_policy = {
min_lifetime = "1d";
max_lifetime = "1y";
};
};
server_name = "c3d2.de";
serve_server_wellknown = true;
url_preview_enabled = true;
user_ips_max_age = "7d";
};
};
2023-04-09 21:13:27 +02:00
matterbridge = {
enable = true;
configPath = config.sops.secrets."matterbridge/config".path;
};
2023-03-24 01:56:38 +01:00
nginx = {
enable = true;
2024-03-14 19:45:37 +01:00
virtualHosts."element.c3d2.de".listen = libC.defaultListen;
2023-03-24 01:56:38 +01:00
virtualHosts."matrix.c3d2.de" = {
forceSSL = true;
enableACME = true;
2024-03-14 19:03:05 +01:00
listen = libC.defaultListen;
2023-03-25 16:05:30 +01:00
locations = {
"/".proxyPass = "http://127.0.0.1:8008";
"^~ /_synapse/admin/".return = "403";
};
2023-03-24 01:56:38 +01:00
};
};
2023-03-25 16:05:30 +01:00
portunus.addToHosts = true;
2023-03-24 01:56:38 +01:00
postgresql = {
enable = true;
ensureUsers = [{
name = "matrix-synapse";
}];
2023-03-25 16:05:30 +01:00
# TODO: move into nixos-modules?
2023-03-24 01:56:38 +01:00
initialScript = pkgs.writeText "synapse-init.sql" ''
CREATE ROLE "matrix-synapse" WITH LOGIN;
CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
TEMPLATE template0
LC_COLLATE = "C"
LC_CTYPE = "C";
'';
2023-09-27 00:01:22 +02:00
package = pkgs.postgresql_16;
2023-03-24 01:56:38 +01:00
upgrade.stopServices = [ "matrix-synapse" ];
};
};
sops = {
defaultSopsFile = ./secrets.yaml;
secrets = {
"matterbridge/config".owner = "matterbridge";
"matrix-synapse/config".owner = "matrix-synapse";
"matrix-synapse/ldapSearchUserPassword".owner = "matrix-synapse";
2023-03-24 01:56:38 +01:00
};
};
system.stateVersion = "22.11";
}