59 lines
1.4 KiB
Nix
Raw Normal View History

2025-02-08 09:27:18 -05:00
{
config,
pkgs,
lib,
2025-02-18 17:44:39 -05:00
hostnames,
2025-02-08 09:27:18 -05:00
...
}:
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;
2025-02-16 10:48:31 -05:00
description = "Hostname for SMTP server";
2025-02-18 17:44:39 -05:00
default = hostnames.smtp;
2025-02-16 10:48:31 -05:00
};
domain = lib.mkOption {
type = lib.types.str;
description = "Domain name for SMTP email";
2025-02-18 17:44:39 -05:00
default = hostnames.mail;
2025-02-08 09:27:18 -05:00
};
user = lib.mkOption {
type = lib.types.str;
2025-02-16 10:48:31 -05:00
description = "Username (email address) for SMTP";
default = "system@${cfg.domain}";
};
passwordFile = lib.mkOption {
type = lib.types.path;
description = "Password file for SMTP";
default = ../../../../../../private/mailpass-system.age;
2025-02-08 09:27:18 -05:00
};
};
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;
2025-02-16 10:48:31 -05:00
passwordeval = "${pkgs.age}/bin/age --decrypt --identity ${config.identityFile} ${pkgs.writeText "mailpass-system.age" (builtins.readFile cfg.passwordFile)}";
2025-02-08 09:27:18 -05:00
user = cfg.user;
from_full_name = "${config.networking.hostName} System";
port = 465;
tls = true;
};
};
};
};
}