renge/mautrix-whatsapp: Use NixOS module
This commit is contained in:
parent
9ee7211cc1
commit
cb289ede0c
|
@ -1,40 +1,28 @@
|
||||||
# SPDX-FileCopyrightText: 2021-2023 Simon Bruder <simon@sbruder.de>
|
# SPDX-FileCopyrightText: 2021-2024 Simon Bruder <simon@sbruder.de>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
# somewhat adapted from https://github.com/NixOS/nixpkgs/pull/59211
|
{ config, ... }:
|
||||||
{ config, lib, pkgs, ... }:
|
|
||||||
let
|
let
|
||||||
synapseCfg = config.services.matrix-synapse.settings;
|
synapseCfg = config.services.matrix-synapse.settings;
|
||||||
in
|
in
|
||||||
let
|
{
|
||||||
config = rec {
|
services.mautrix-whatsapp = {
|
||||||
|
enable = true;
|
||||||
|
settings = rec {
|
||||||
homeserver = {
|
homeserver = {
|
||||||
address = synapseCfg.public_baseurl;
|
address = synapseCfg.public_baseurl;
|
||||||
domain = synapseCfg.server_name;
|
domain = synapseCfg.server_name;
|
||||||
};
|
};
|
||||||
appservice = rec {
|
appservice = {
|
||||||
hostname = "127.0.0.1";
|
|
||||||
port = 29318;
|
|
||||||
address = "http://${hostname}:${toString port}";
|
|
||||||
provisioning.shared_secret = "disable";
|
provisioning.shared_secret = "disable";
|
||||||
database = {
|
bot.avatar = "mxc://maunium.net/NeXNQarUbrlYBiPCpprYsRqr";
|
||||||
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 = {
|
whatsapp = {
|
||||||
browser_name = "mx-wa";
|
browser_name = "mx-wa";
|
||||||
os_name = "Mautrix-WhatsApp bridge";
|
os_name = "Mautrix-WhatsApp bridge";
|
||||||
};
|
};
|
||||||
bridge = {
|
bridge = {
|
||||||
command_prefix = "!wa";
|
|
||||||
delivery_receipts = true;
|
delivery_receipts = true;
|
||||||
displayname_template = "{{if .FullName}}{{.FullName}}{{else if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)";
|
displayname_template = "{{if .FullName}}{{.FullName}}{{else if .Notify}}{{.Notify}}{{else}}{{.Jid}}{{end}} (WA)";
|
||||||
history_sync = {
|
history_sync = {
|
||||||
|
@ -50,36 +38,6 @@ let
|
||||||
reaction_notices = true;
|
reaction_notices = true;
|
||||||
relay.enable = false;
|
relay.enable = false;
|
||||||
};
|
};
|
||||||
logging = {
|
|
||||||
print_level = "info";
|
|
||||||
file_name_format = null;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
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.settings.app_service_config_files = lib.singleton "${generatedConfig}/registration.yaml";
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue