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; + }; +}