72 lines
1.8 KiB
Nix
72 lines
1.8 KiB
Nix
{ 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_EMAIL_DOMAIN}";
|
|
};
|
|
smtpUsername = lib.mkOption {
|
|
description = "The SMTP username";
|
|
type = lib.types.str;
|
|
default = "${SENDER_EMAIL_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 <--
|
|
|
|
|
|
|
|
### --> SMART disk heath
|
|
services.smartd = {
|
|
enable = true;
|
|
defaults.autodetected = "-a -o on -S on -s (S/../.././02|L/../../6/03) -n standby,q";
|
|
notifications = {
|
|
wall = {
|
|
enable = true;
|
|
};
|
|
mail = {
|
|
enable = true;
|
|
sender = config.email.fromAddress;
|
|
recipient = config.email.toAddress;
|
|
};
|
|
};
|
|
};
|
|
### SMART disk heath <--
|
|
|
|
} |