Merge pull request #109345 from cole-h/zfs-closure
Shrink the ZFS closure by making mail support optional
This commit is contained in:
commit
e4cf0e7a45
@ -326,30 +326,36 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
services.zfs.zed.settings = mkOption {
|
||||
type = with types; attrsOf (oneOf [ str int bool (listOf str) ]);
|
||||
example = literalExample ''
|
||||
{
|
||||
ZED_DEBUG_LOG = "/tmp/zed.debug.log";
|
||||
services.zfs.zed = {
|
||||
enableMail = mkEnableOption "ZED's ability to send emails" // {
|
||||
default = cfgZfs.package.enableMail;
|
||||
};
|
||||
|
||||
ZED_EMAIL_ADDR = [ "root" ];
|
||||
ZED_EMAIL_PROG = "mail";
|
||||
ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@";
|
||||
settings = mkOption {
|
||||
type = with types; attrsOf (oneOf [ str int bool (listOf str) ]);
|
||||
example = literalExample ''
|
||||
{
|
||||
ZED_DEBUG_LOG = "/tmp/zed.debug.log";
|
||||
|
||||
ZED_NOTIFY_INTERVAL_SECS = 3600;
|
||||
ZED_NOTIFY_VERBOSE = false;
|
||||
ZED_EMAIL_ADDR = [ "root" ];
|
||||
ZED_EMAIL_PROG = "mail";
|
||||
ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@";
|
||||
|
||||
ZED_USE_ENCLOSURE_LEDS = true;
|
||||
ZED_SCRUB_AFTER_RESILVER = false;
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
ZFS Event Daemon /etc/zfs/zed.d/zed.rc content
|
||||
ZED_NOTIFY_INTERVAL_SECS = 3600;
|
||||
ZED_NOTIFY_VERBOSE = false;
|
||||
|
||||
See
|
||||
<citerefentry><refentrytitle>zed</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
||||
for details on ZED and the scripts in /etc/zfs/zed.d to find the possible variables
|
||||
'';
|
||||
ZED_USE_ENCLOSURE_LEDS = true;
|
||||
ZED_SCRUB_AFTER_RESILVER = false;
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
ZFS Event Daemon /etc/zfs/zed.d/zed.rc content
|
||||
|
||||
See
|
||||
<citerefentry><refentrytitle>zed</refentrytitle><manvolnum>8</manvolnum></citerefentry>
|
||||
for details on ZED and the scripts in /etc/zfs/zed.d to find the possible variables
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@ -358,6 +364,14 @@ in
|
||||
config = mkMerge [
|
||||
(mkIf cfgZfs.enabled {
|
||||
assertions = [
|
||||
{
|
||||
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";
|
||||
@ -437,7 +451,7 @@ in
|
||||
};
|
||||
|
||||
services.zfs.zed.settings = {
|
||||
ZED_EMAIL_PROG = mkDefault "${pkgs.mailutils}/bin/mail";
|
||||
ZED_EMAIL_PROG = mkIf cfgZED.enableMail (mkDefault "${pkgs.mailutils}/bin/mail");
|
||||
PATH = lib.makeBinPath [
|
||||
cfgZfs.package
|
||||
pkgs.coreutils
|
||||
|
@ -8,8 +8,8 @@
|
||||
, libtirpc
|
||||
, nfs-utils
|
||||
, gawk, gnugrep, gnused, systemd
|
||||
, smartmontools, sysstat, sudo
|
||||
, pkg-config
|
||||
, smartmontools, enableMail ? false
|
||||
, sysstat, sudo, pkg-config
|
||||
|
||||
# Kernel dependencies
|
||||
, kernel ? null
|
||||
@ -18,6 +18,8 @@
|
||||
|
||||
with lib;
|
||||
let
|
||||
smartmon = smartmontools.override { inherit enableMail; };
|
||||
|
||||
buildKernel = any (n: n == configFile) [ "kernel" "all" ];
|
||||
buildUser = any (n: n == configFile) [ "user" "all" ];
|
||||
|
||||
@ -148,7 +150,7 @@ let
|
||||
'';
|
||||
|
||||
postFixup = let
|
||||
path = "PATH=${makeBinPath [ coreutils gawk gnused gnugrep util-linux smartmontools sysstat ]}:$PATH";
|
||||
path = "PATH=${makeBinPath [ coreutils gawk gnused gnugrep util-linux smartmon sysstat ]}:$PATH";
|
||||
in ''
|
||||
for i in $out/libexec/zfs/zpool.d/*; do
|
||||
sed -i '2i${path}' $i
|
||||
@ -157,12 +159,17 @@ let
|
||||
|
||||
outputs = [ "out" ] ++ optionals buildUser [ "lib" "dev" ];
|
||||
|
||||
passthru.tests = if isUnstable then
|
||||
[ nixosTests.zfs.unstable ]
|
||||
else [
|
||||
nixosTests.zfs.installer
|
||||
nixosTests.zfs.stable
|
||||
];
|
||||
passthru = {
|
||||
inherit enableMail;
|
||||
|
||||
tests =
|
||||
if isUnstable then [
|
||||
nixosTests.zfs.unstable
|
||||
] else [
|
||||
nixosTests.zfs.installer
|
||||
nixosTests.zfs.stable
|
||||
];
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "ZFS Filesystem Linux Kernel module";
|
||||
|
@ -1,5 +1,6 @@
|
||||
{ lib, stdenv, fetchurl, autoreconfHook
|
||||
, mailutils, inetutils
|
||||
, mailutils, enableMail ? true
|
||||
, inetutils
|
||||
, IOKit, ApplicationServices }:
|
||||
|
||||
let
|
||||
@ -26,7 +27,7 @@ in stdenv.mkDerivation rec {
|
||||
postPatch = "cp -v ${driverdb} drivedb.h";
|
||||
|
||||
configureFlags = [
|
||||
"--with-scriptpath=${lib.makeBinPath [ mailutils inetutils ]}"
|
||||
"--with-scriptpath=${lib.makeBinPath ([ inetutils ] ++ lib.optional enableMail mailutils)}"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ autoreconfHook ];
|
||||
|
Loading…
Reference in New Issue
Block a user