{ povSelf, pkgs, lib, config, hostConfig, ... }: let inherit (lib) types; cfg = lib.getAttrFromPath povSelf config; in { options.enable = { type = types.bool; default = false; }; config = lib.mkIf cfg.enable { assertions = [ { assertion = config.modules.websites."grapevine.zaphyra.eu".enable == true; message = "The option 'modules.websites.\"grapevine.zaphyra.eu\"' must be enabled in order to use this module."; } ]; sops.secrets."environments/mautrixBridges/whatsapp" = { }; modules.services.mautrixBridge.whatsapp = { enable = true; package = pkgs.mautrix-whatsapp.override { withGoolm = true; }; serviceDependencies = [ "grapevine.service" ]; environmentFile = config.sops.secrets."environments/mautrixBridges/whatsapp".path; settings = rec { network = { displayname_template = "{{or .BusinessName .PushName .Phone}} (WA)"; os_name = "Mautrix-WhatsApp (on ${homeserver.domain})"; identity_change_notices = true; url_previews = true; history_sync = { request_full_sync = true; full_sync_config.days_limit = 1000; full_sync_config.size_mb_limit = 1024; full_sync_config.storage_quota_mb = 1024; }; }; homeserver.address = "http://[::1]:6167/"; homeserver.domain = "zaphyra.eu"; database.type = "sqlite3-fk-wal"; database.uri = "file:/var/lib/mautrix-whatsapp/mautrix-whatsapp.db?_txlock=immediate"; encryption.allow = true; encryption.default = true; encryption.pickle_key = "$MAUTRIX_PICKLE_KEY"; relay.enabled = false; backfill.enabled = true; backfill.max_initial_messages = 100; # double_puppet.secrets."${homeserver.domain}" = "as_token:$MAUTRIX_DOUBLE_PUPPET_SHARED_SECRET"; appservice = { id = "whatsapp"; address = "http://[::1]:29318/"; hostname = "[::1]"; port = 29318; as_token = "$MAUTRIX_AS_TOKEN"; hs_token = "$MAUTRIX_HS_TOKEN"; }; bridge = { personal_filtering_spaces = true; permissions."${homeserver.domain}" = "admin"; cleanup_on_logout = { enabled = true; } // (lib.genAttrs [ "manual" "bad_credentials" ] (name: { shared_has_users = "delete"; shared_no_users = "delete"; relayed = "delete"; private = "delete"; })); }; }; }; }; }