40 lines
943 B
Nix
Raw Normal View History

2025-01-20 22:35:40 -05:00
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.msmtp;
in
{
options.nmasur.presets.programs.msmtp.enable = lib.mkEnableOption "System outgoing mail";
config = lib.mkIf cfg.enable {
programs.msmtp.enable = true;
# The system user for sending automatic notifications
accounts.email.accounts.system =
let
address = "system@${config.mail.server}";
in
{
userName = address;
realName = "NixOS System";
primary = !config.mail.enable; # Only primary if mail not enabled
inherit address;
passwordCommand = "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${pkgs.writeText "mailpass-system.age" (builtins.readFile ../../../private/mailpass-system.age)}";
msmtp.enable = true;
smtp = {
host = config.mail.smtpHost;
port = 465;
tls.enable = true;
};
};
};
}