Simon Bruder
ebfa0ec16a
Sadly, they are so interconnected, that it is not easily possible to migrate it in smaller steps. It should be refactored to make them more modularised and independent of each other.
79 lines
2.4 KiB
Nix
79 lines
2.4 KiB
Nix
# somewhat adapted from https://github.com/NixOS/nixpkgs/pull/59211
|
|
{ config, lib, pkgs, ... }:
|
|
let
|
|
synapseCfg = config.services.matrix-synapse;
|
|
in
|
|
let
|
|
config = rec {
|
|
homeserver = {
|
|
address = synapseCfg.public_baseurl;
|
|
domain = synapseCfg.server_name;
|
|
};
|
|
appservice = rec {
|
|
hostname = "127.0.0.1";
|
|
port = 29318;
|
|
address = "http://${hostname}:${toString port}";
|
|
provisioning.shared_secret = "disable";
|
|
database = {
|
|
type = "sqlite3";
|
|
uri = "/var/lib/mautrix-whatsapp/mautrix-whatsapp.db";
|
|
};
|
|
id = "whatsapp";
|
|
bot = {
|
|
username = "whatsappbot";
|
|
displayname = "WhatsApp bridge bot";
|
|
avatar = "mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr";
|
|
};
|
|
};
|
|
whatsapp = {
|
|
browser_name = "mx-wa";
|
|
os_name = "Mautrix-WhatsApp bridge";
|
|
};
|
|
bridge = {
|
|
command_prefix = "!wa";
|
|
delivery_receipts = true;
|
|
displayname_template = "{{if .FullName}}{{.FullName}}{{else if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)";
|
|
history_sync = {
|
|
backfill = true;
|
|
};
|
|
identity_change_notices = true;
|
|
permissions = {
|
|
# Only one user since using the name from the address book does not
|
|
# work with multiple users
|
|
"@simon:${homeserver.domain}" = 100;
|
|
};
|
|
private_chat_portal_meta = true;
|
|
reaction_notices = true;
|
|
relay.enable = false;
|
|
};
|
|
logging.print_level = "info";
|
|
};
|
|
|
|
generatedConfig = pkgs.runCommandNoCC "mautrix-whatsapp-config"
|
|
{
|
|
buildInputs = with pkgs; [ mautrix-whatsapp ];
|
|
}
|
|
''
|
|
mkdir $out
|
|
cat ${pkgs.writeText "mautrix-whatsapp.yaml" (lib.generators.toYAML { } config)} > $out/config.yaml
|
|
mautrix-whatsapp -c $out/config.yaml -g -r $out/registration.yaml
|
|
'';
|
|
in
|
|
{
|
|
systemd.services.mautrix-whatsapp = {
|
|
description = "Mautrix-WhatsApp Service - A WhatsApp bridge for Matrix";
|
|
after = [ "network.target" "matrix-synapse.service" ];
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
DynamicUser = true;
|
|
StateDirectory = "mautrix-whatsapp";
|
|
WorkingDirectory = "/var/lib/mautrix-whatsapp";
|
|
ExecStart = "${pkgs.mautrix-whatsapp}/bin/mautrix-whatsapp -c ${generatedConfig}/config.yaml";
|
|
Restart = "on-failure";
|
|
};
|
|
};
|
|
|
|
services.matrix-synapse.app_service_config_files = lib.singleton "${generatedConfig}/registration.yaml";
|
|
}
|