From d31e293cef03b1804d8d9652de78e7f6c39d72d5 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sat, 22 May 2021 16:09:11 +0200 Subject: [PATCH] home: mail: add msmtp --- home/mail/accounts.nix | 8 +++++++- home/mail/default.nix | 14 ++++++++++++++ home/mail/msmtp.nix | 9 +++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 home/mail/msmtp.nix diff --git a/home/mail/accounts.nix b/home/mail/accounts.nix index 8a3e1eb..7f1ad02 100644 --- a/home/mail/accounts.nix +++ b/home/mail/accounts.nix @@ -1,5 +1,7 @@ -{ lib, pkgs, ... }: +{ config, lib, pkgs, ... }: let + cfg = config.my.home.mail; + mkAddress = address: domain: "${address}@${domain}"; mkConfig = { domain, address, passName, aliases ? [ ], primary ? false }: { @@ -12,6 +14,10 @@ let aliases = builtins.map (lib.flip mkAddress domain) aliases; inherit primary; + + msmtp = { + enable = cfg.msmtp.enable; + }; }; migaduConfig = { diff --git a/home/mail/default.nix b/home/mail/default.nix index 32c918e..cc81d0c 100644 --- a/home/mail/default.nix +++ b/home/mail/default.nix @@ -1,9 +1,23 @@ { config, lib, ... }: +let + cfg = config.my.home.mail; + + mkRelatedOption = desc: lib.mkEnableOption desc // { default = cfg.enable; }; +in { imports = [ ./accounts.nix + ./msmtp.nix ]; + options.my.home.mail = with lib; { + enable = my.mkDisableOption "email configuration"; + + msmtp = { + enable = mkRelatedOption "msmtp configuration"; + }; + }; + config = { accounts.email = { maildirBasePath = "mail"; diff --git a/home/mail/msmtp.nix b/home/mail/msmtp.nix new file mode 100644 index 0000000..3e725e8 --- /dev/null +++ b/home/mail/msmtp.nix @@ -0,0 +1,9 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.my.home.mail.msmtp; +in +{ + config.programs.msmtp = lib.mkIf cfg.enable { + enable = true; + }; +}