mail stuff

This commit is contained in:
Noah Masur 2025-02-08 09:27:18 -05:00
parent 1e5fd5d9ae
commit 9c5de4c54f
No known key found for this signature in database
3 changed files with 48 additions and 40 deletions

View File

@ -1,39 +0,0 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.msmtp-system;
in
{
options.nmasur.presets.programs.msmtp-system.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;
};
};
};
}

View File

@ -0,0 +1,47 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.nmasur.presets.programs.msmtp;
in
{
options.nmasur.presets.programs.msmtp = {
enable = lib.mkEnableOption "System outgoing mail";
host = lib.mkOption {
type = lib.types.str;
description = "Hostname for SMTP";
default = config.mail.smtpHost;
};
user = lib.mkOption {
type = lib.types.str;
description = "system@${config.mail.server}";
default = config.mail.smtpHost;
};
};
config = lib.mkIf cfg.enable {
programs.msmtp = {
enable = true;
setSendmail = true;
accounts = {
# The system user for sending automatic notifications
default = {
auth = true;
host = cfg.host;
passwordeval = "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${pkgs.writeText "mailpass-system.age" (builtins.readFile ../../../private/mailpass-system.age)}";
user = cfg.user;
from_full_name = "${config.networking.hostName} System";
port = 465;
tls = true;
};
};
};
};
}

View File

@ -24,7 +24,7 @@ in
default = "/var/private";
};
secretsIdentityFile = lib.mkOption {
identityFile = lib.mkOption {
type = lib.types.path;
description = "Path containing decryption identity.";
};