Matrix configuration #13

Merged
fugidev merged 7 commits from matrix into main 2023-02-03 15:10:19 +01:00
2 changed files with 127 additions and 0 deletions
Showing only changes of commit 565bcae081 - Show all commits

View file

@ -64,6 +64,7 @@
./modules/wiki.nix ./modules/wiki.nix
./modules/stream.nix ./modules/stream.nix
./modules/nextcloud.nix ./modules/nextcloud.nix
./modules/matrix.nix
{ {
sops.defaultSopsFile = ./secrets/quitte.yaml; sops.defaultSopsFile = ./secrets/quitte.yaml;
} }

126
modules/matrix.nix Normal file
View file

@ -0,0 +1,126 @@
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
{ config, pkgs, lib, ... }:
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
let
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
domain = "staging.ifsr.de";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
domainServer = "matrix.${domain}";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
domainClient = "chat.${domain}";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
clientConfig = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
"m.homeserver" = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
base_url = "https://${domainServer}:443";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
server_name = domainServer;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
"m.identity_server" = {};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
serverConfig = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
"m.server" = "${domainServer}:443";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
mkWellKnown = data: ''
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
add_header Content-Type application/json;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
add_header Access-Control-Allow-Origin *;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
return 200 '${builtins.toJSON data}';
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
'';
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
in
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
{
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
#sops.secrets = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# synapse_registration_secret = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# owner = "matrix-synapse";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# group = "matrix-synapse";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# };
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
#};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
services = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
postgresql = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
enable = true;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
ensureUsers = [
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
{
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
name = "matrix-synapse";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
}
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
];
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
nginx = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
recommendedProxySettings = true;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
virtualHosts = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# synapse
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
"${domainServer}" = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
enableACME = true;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
forceSSL = true;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# homeserver discovery
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
locations."= /.well-known/matrix/client".extraConfig = mkWellKnown clientConfig;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
locations."= /.well-known/matrix/server".extraConfig = mkWellKnown serverConfig;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# 404 on /
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
locations."/".extraConfig = "return 404;";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# proxy to synapse
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
locations."/_matrix".proxyPass = "http://[::1]:8008";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
locations."/_synapse/client".proxyPass = "http://[::1]:8008";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# element
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
"${domainClient}" = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
enableACME = true;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
forceSSL = true;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
root = pkgs.element-web.override {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
conf = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
default_server_config = clientConfig;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
matrix-synapse = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
enable = true;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
settings = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
server_name = domainServer;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
listeners = [{
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
port = 8008;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
bind_addresses = [ "::1" ];
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
type = "http";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tls = false;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
x_forwarded = true;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
resources = [{
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
names = [ "client" "federation" ];
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
compress = false;
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
}];
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
}];
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# TODO: ldap
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
registration_shared_secret = "registration_shared_secret";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# extraConfigFiles = [
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# (pkgs.writeTextFile {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# name = "matrix-synapse-extra-config.yml";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# text = ''
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# '';
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# })
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# ];
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
systemd.services.matrix-synapse.after = [ "matrix-synapse-pgsetup.service" ];
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
systemd.services.matrix-synapse-pgsetup = {
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
description = "Prepare Synapse postgres database";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
wantedBy = [ "multi-user.target" ];
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
after = [ "networking.target" "postgresql.service" ];
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
serviceConfig.Type = "oneshot";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
path = [ pkgs.sudo config.services.postgresql.package ];
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
# create database for synapse. will silently fail if already exists
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
script = ''
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
sudo -u ${config.services.postgresql.superUser} psql <<SQL
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
CREATE DATABASE "matrix-synapse" WITH OWNER "matrix-synapse"
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
ENCODING 'UTF8'
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
TEMPLATE template0
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
LC_COLLATE = "C"
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
LC_CTYPE = "C";
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
SQL
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
'';
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
};
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option
}
tanneberger commented 2022-12-17 19:43:15 +01:00 (Migrated from github.com)
Review

nixos domain option

nixos domain option