nixos-config/modules/matrix-synapse.nix

90 lines
2.7 KiB
Nix
Raw Normal View History

2020-04-29 03:18:36 +04:00
{ pkgs, config, lib, ... }: lib.mkIf (! isNull config.secrets.matrix) {
2020-02-17 17:00:59 +04:00
services.matrix-synapse = {
enable = true;
allow_guest_access = true;
listeners = [{
bind_address = "0.0.0.0";
port = 13748;
resources = [
{
compress = true;
names = [ "client" ];
}
{
compress = false;
names = [ "federation" ];
}
];
type = "http";
2020-07-30 00:50:51 +04:00
tls = false;
x_forwarded = true;
2020-02-17 17:00:59 +04:00
}];
registration_shared_secret = config.secrets.matrix.shared_secret;
public_baseurl = "https://balsoft.ru";
2020-02-17 17:00:59 +04:00
server_name = "balsoft.ru";
app_service_config_files = [
(builtins.toFile "registration_tg.yaml"
(builtins.toJSON config.secrets.matrix.mautrix-telegram.registration))
(builtins.toFile "registration_wa.yaml"
(builtins.toJSON config.secrets.matrix.mautrix-whatsapp.registration))
];
};
services.postgresql.enable = true;
2020-02-26 15:42:13 +04:00
home-manager.users.balsoft.xsession.windowManager.i3.config.startup = [{
command = "anbox launch --package=com.whatsapp --component=.HomeActivity";
}];
2020-02-17 17:00:59 +04:00
systemd.services.mautrix-whatsapp = {
description = "A bridge between whatsapp and matrix";
path = with pkgs; [ coreutils mautrix-whatsapp ];
wantedBy = [ "multi-user.target" ];
requires = [
"matrix-synapse.service"
"network-online.target"
];
serviceConfig = {
Restart = "always";
RestartSec = 1;
};
script = ''
mkdir -p /var/lib/mautrix-whatsapp
cd /var/lib/mautrix-whatsapp
sleep 5
2020-08-04 15:51:37 +04:00
mautrix-whatsapp -c ${
2020-02-17 17:00:59 +04:00
builtins.toFile "config_wa.yaml"
2020-08-04 15:51:37 +04:00
(builtins.toJSON config.secrets.matrix.mautrix-whatsapp.config)
2020-02-17 17:00:59 +04:00
}
'';
};
2020-08-04 15:51:37 +04:00
# systemd.services.mautrix-telegram = {
# description = "A bridge between telegram and matrix";
# requires = [ "matrix-synapse.service" ];
# path = with pkgs; [ coreutils mautrix-telegram ];
# serviceConfig = {
# Restart = "always";
# RestartSec = 1;
# };
# wantedBy = [ "network-online.target" ];
# script = ''
# mkdir -p /var/lib/mautrix-telegram
# cp -r ${pkgs.mautrix-telegram}/* /var/lib/mautrix-telegram
# cd /var/lib/mautrix-telegram
# alembic upgrade head || echo "update failed"
# sleep 5
# cp ${
# builtins.toFile "config.yaml"
# (builtins.toJSON config.secrets.matrix.mautrix-telegram.config)
# } ./config.yaml
# timeout 900 mautrix-telegram
# '';
# };
services.mautrix-telegram = {
enable = true;
settings = config.secrets.matrix.mautrix-telegram.config;
2020-02-17 17:00:59 +04:00
};
2020-08-04 15:51:37 +04:00
systemd.services.mautrix-telegram.serviceConfig.DynamicUser = lib.mkForce false;
2020-02-17 17:00:59 +04:00
users.users.matrix-synapse.name = lib.mkForce "matrix-synapse";
}