0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

nixos/zed: use global sendmail if configured

This simplifies the setup to receive emails from the ZFS Event Daemon
by relying on the sendmail wrapper defined by other modules such as
msmtp or Postfix.

This is more similar to how other modules like smartd deal with email
configuration.

The user is no longer required to define and rebuild their own ZFS
package to add email support.

GitHub: closes https://github.com/NixOS/nixpkgs/issues/132464
This commit is contained in:
pacien 2023-12-17 17:17:24 +01:00
parent 1272bba187
commit cf6d89525f
2 changed files with 19 additions and 12 deletions

View file

@ -508,9 +508,15 @@ in
};
services.zfs.zed = {
enableMail = mkEnableOption (lib.mdDoc "ZED's ability to send emails") // {
default = cfgZfs.package.enableMail;
defaultText = literalExpression "config.${optZfs.package}.enableMail";
enableMail = mkOption {
type = types.bool;
default = config.services.mail.sendmailSetuidWrapper != null;
defaultText = literalExpression ''
config.services.mail.sendmailSetuidWrapper != null
'';
description = mdDoc ''
Whether to enable ZED's ability to send emails.
'';
};
settings = mkOption {
@ -550,14 +556,6 @@ in
assertion = cfgZfs.modulePackage.version == cfgZfs.package.version;
message = "The kernel module and the userspace tooling versions are not matching, this is an unsupported usecase.";
}
{
assertion = cfgZED.enableMail -> cfgZfs.package.enableMail;
message = ''
To allow ZED to send emails, ZFS needs to be configured to enable
this. To do so, one must override the `zfs` package and set
`enableMail` to true.
'';
}
{
assertion = config.networking.hostId != null;
message = "ZFS requires networking.hostId to be set";
@ -671,7 +669,13 @@ in
};
services.zfs.zed.settings = {
ZED_EMAIL_PROG = mkIf cfgZED.enableMail (mkDefault "${pkgs.mailutils}/bin/mail");
ZED_EMAIL_PROG = mkIf cfgZED.enableMail (mkDefault (
config.security.wrapperDir + "/" +
config.services.mail.sendmailSetuidWrapper.program
));
# subject in header for sendmail
ZED_EMAIL_OPTS = mkIf cfgZED.enableMail (mkDefault "@ADDRESS@");
PATH = lib.makeBinPath [
cfgZfs.package
pkgs.coreutils