{ config, pkgs, lib, ... }: let cfg = config.email; in ### --> Mail notifications configuration { options.email = { enable = lib.mkEnableOption "Email sending functionality"; fromAddress = lib.mkOption { description = "The 'from' address"; type = lib.types.str; default = "no-reply@DOMAIN_NAME"; }; toAddress = lib.mkOption { description = "The 'to' address"; type = lib.types.str; default = "EMAIL_ADDRESS"; }; smtpServer = lib.mkOption { description = "The SMTP server address"; type = lib.types.str; default = "SENDER_MAIL_DOMAIN"; }; smtpUsername = lib.mkOption { description = "The SMTP username"; type = lib.types.str; default = "SENDER_MAIL_ADDRESS"; }; smtpPasswordPath = lib.mkOption { description = "Path to the secret containing SMTP password"; type = lib.types.path; default = config.sops.secrets.sender_email_address_password.path; }; }; config = lib.mkIf cfg.enable { programs.msmtp = { enable = true; accounts.default = { auth = true; host = config.email.smtpServer; from = config.email.fromAddress; user = config.email.smtpUsername; tls = true; passwordeval = "${pkgs.coreutils}/bin/cat ${config.email.smtpPasswordPath}"; }; }; }; ### Mail notifications configuration <-- }