From 3a1f5757b9684c2636ffae30169f68eba08e2e0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Christ?= Date: Sun, 6 Aug 2023 11:03:17 +0200 Subject: [PATCH] mautrix-whatsapp: move defaults back to options. As suggested by @nickcao this commit moves the defaults back to the options. Only `homeserver.domain` stays in the config section since the documentation module does not support referencing attributes of other modules. --- .../services/matrix/mautrix-whatsapp.nix | 83 +++++++++---------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/nixos/modules/services/matrix/mautrix-whatsapp.nix b/nixos/modules/services/matrix/mautrix-whatsapp.nix index c047d6638854..80c85980196f 100644 --- a/nixos/modules/services/matrix/mautrix-whatsapp.nix +++ b/nixos/modules/services/matrix/mautrix-whatsapp.nix @@ -18,7 +18,46 @@ in { settings = lib.mkOption { type = settingsFormat.type; - default = {}; + default = { + appservice = { + address = "http://localhost:${toString appservicePort}"; + hostname = "[::]"; + port = appservicePort; + database = { + type = "sqlite3"; + uri = "${dataDir}/mautrix-whatsapp.db"; + }; + id = "whatsapp"; + bot = { + username = "whatsappbot"; + displayname = "WhatsApp Bridge Bot"; + }; + as_token = ""; + hs_token = ""; + }; + bridge = { + username_template = "whatsapp_{{.}}"; + displayname_template = "{{if .BusinessName}}{{.BusinessName}}{{else if .PushName}}{{.PushName}}{{else}}{{.JID}}{{end}} (WA)"; + double_puppet_server_map = {}; + login_shared_secret_map = {}; + command_prefix = "!wa"; + permissions."*" = "relay"; + relay.enabled = true; + }; + logging = { + min_level = "info"; + writers = [ + { + type = "stdout"; + format = "pretty-colored"; + } + { + type = "file"; + format = "json"; + } + ]; + }; + }; description = lib.mdDoc '' {file}`config.yaml` configuration as a Nix attribute set. Configuration options should match those described in @@ -79,47 +118,7 @@ in { config = lib.mkIf cfg.enable { services.mautrix-whatsapp.settings = { - homeserver = { - domain = lib.mkDefault config.services.matrix-synapse.settings.server_name; - }; - appservice = { - address = lib.mkDefault "http://localhost:${toString appservicePort}"; - hostname = lib.mkDefault "[::]"; - port = lib.mkDefault appservicePort; - database = { - type = lib.mkDefault "sqlite3"; - uri = lib.mkDefault "${dataDir}/mautrix-whatsapp.db"; - }; - id = lib.mkDefault "whatsapp"; - bot = { - username = lib.mkDefault "whatsappbot"; - displayname = lib.mkDefault "WhatsApp Bridge Bot"; - }; - as_token = lib.mkDefault ""; - hs_token = lib.mkDefault ""; - }; - bridge = { - username_template = lib.mkDefault "whatsapp_{{.}}"; - displayname_template = lib.mkDefault "{{if .BusinessName}}{{.BusinessName}}{{else if .PushName}}{{.PushName}}{{else}}{{.JID}}{{end}} (WA)"; - double_puppet_server_map = lib.mkDefault {}; - login_shared_secret_map = lib.mkDefault {}; - command_prefix = lib.mkDefault "!wa"; - permissions."*" = lib.mkDefault "relay"; - relay.enabled = lib.mkDefault true; - }; - logging = { - min_level = lib.mkDefault "info"; - writers = [ - { - type = lib.mkDefault "stdout"; - format = lib.mkDefault "pretty-colored"; - } - { - type = lib.mkDefault "file"; - format = lib.mkDefault "json"; - } - ]; - }; + homeserver.domain = lib.mkDefault config.services.matrix-synapse.settings.server_name; }; systemd.services.mautrix-whatsapp = {