From ee21de5b948b08a29f3d79da0c17a6d84b11a119 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 9 Jun 2021 18:54:16 +0200 Subject: [PATCH] modules: services: matrix: add mail configuration --- machines/porthos/services.nix | 1 + modules/services/matrix.nix | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/machines/porthos/services.nix b/machines/porthos/services.nix index 9773007..44c0b50 100644 --- a/machines/porthos/services.nix +++ b/machines/porthos/services.nix @@ -65,6 +65,7 @@ in # Matrix backend and Element chat front-end matrix = { enable = true; + mail = my.secrets.matrix.mail; secret = my.secrets.matrix.secret; }; miniflux = { diff --git a/modules/services/matrix.nix b/modules/services/matrix.nix index 68468f0..fd4e90c 100644 --- a/modules/services/matrix.nix +++ b/modules/services/matrix.nix @@ -18,11 +18,46 @@ in { options.my.services.matrix = with lib; { enable = mkEnableOption "Matrix Synapse"; + secret = mkOption { type = types.str; example = "deadbeef"; description = "Shared secret to register users"; }; + + mail = { + host = mkOption { + type = types.str; + default = "smtp.migadu.com"; + example = "smtp.example.com"; + description = "Which host should be used for SMTP"; + }; + + port = mkOption { + type = types.port; + default = 587; + example = 25; + description = "Which port should be used for SMTP"; + }; + + username = mkOption { + type = types.str; + example = "matrix@example.com"; + description = "Which username should be used to connect"; + }; + + password = mkOption { + type = types.str; + example = "password"; + description = "Which password should be used to connect"; + }; + + notifFrom = mkOption { + type = types.str; + example = ""; + description = "Which address should be used for `From` field"; + }; + }; }; config = lib.mkIf cfg.enable { @@ -72,6 +107,15 @@ in extraConfig = '' experimental_features: spaces_enabled: true + + email: + smtp_host: "${cfg.mail.host}" + smtp_port: ${toString cfg.mail.port} + smtp_user: "${cfg.mail.username}" + smtp_pass: "${cfg.mail.password}" + notif_from: "${cfg.mail.notifFrom}" + # Refuse to connect unless the server supports STARTTLS. + require_transport_security: true ''; };