dotfiles/modules/common/mail/system.nix

35 lines
941 B
Nix
Raw Normal View History

2023-07-29 03:28:08 +00:00
{ config, pkgs, lib, ... }: {
config = lib.mkIf (config.mail.enable || config.server) {
home-manager.users.${config.user} = {
programs.msmtp.enable = true;
2023-07-29 19:20:14 +00:00
# The system user for sending automatic notifications
2023-07-29 03:28:08 +00:00
accounts.email.accounts.system =
let address = "system@${config.mail.server}";
in {
userName = address;
realName = "NixOS System";
2023-07-29 19:20:14 +00:00
primary = !config.mail.enable; # Only primary if mail not enabled
2023-07-29 03:28:08 +00:00
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;
};
};
};
};
}