Merge pull request #109345 from cole-h/zfs-closure

Shrink the ZFS closure by making mail support optional
This commit is contained in:
Linus Heckemann 2021-02-10 23:04:24 +01:00 committed by GitHub
commit e4cf0e7a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 32 deletions

View File

@ -326,30 +326,36 @@ in
}; };
}; };
services.zfs.zed.settings = mkOption { services.zfs.zed = {
type = with types; attrsOf (oneOf [ str int bool (listOf str) ]); enableMail = mkEnableOption "ZED's ability to send emails" // {
example = literalExample '' default = cfgZfs.package.enableMail;
{ };
ZED_DEBUG_LOG = "/tmp/zed.debug.log";
ZED_EMAIL_ADDR = [ "root" ]; settings = mkOption {
ZED_EMAIL_PROG = "mail"; type = with types; attrsOf (oneOf [ str int bool (listOf str) ]);
ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@"; example = literalExample ''
{
ZED_DEBUG_LOG = "/tmp/zed.debug.log";
ZED_NOTIFY_INTERVAL_SECS = 3600; ZED_EMAIL_ADDR = [ "root" ];
ZED_NOTIFY_VERBOSE = false; ZED_EMAIL_PROG = "mail";
ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@";
ZED_USE_ENCLOSURE_LEDS = true; ZED_NOTIFY_INTERVAL_SECS = 3600;
ZED_SCRUB_AFTER_RESILVER = false; ZED_NOTIFY_VERBOSE = false;
}
'';
description = ''
ZFS Event Daemon /etc/zfs/zed.d/zed.rc content
See ZED_USE_ENCLOSURE_LEDS = true;
<citerefentry><refentrytitle>zed</refentrytitle><manvolnum>8</manvolnum></citerefentry> ZED_SCRUB_AFTER_RESILVER = false;
for details on ZED and the scripts in /etc/zfs/zed.d to find the possible variables }
''; '';
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 [ config = mkMerge [
(mkIf cfgZfs.enabled { (mkIf cfgZfs.enabled {
assertions = [ 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; assertion = config.networking.hostId != null;
message = "ZFS requires networking.hostId to be set"; message = "ZFS requires networking.hostId to be set";
@ -437,7 +451,7 @@ in
}; };
services.zfs.zed.settings = { 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 [ PATH = lib.makeBinPath [
cfgZfs.package cfgZfs.package
pkgs.coreutils pkgs.coreutils

View File

@ -8,8 +8,8 @@
, libtirpc , libtirpc
, nfs-utils , nfs-utils
, gawk, gnugrep, gnused, systemd , gawk, gnugrep, gnused, systemd
, smartmontools, sysstat, sudo , smartmontools, enableMail ? false
, pkg-config , sysstat, sudo, pkg-config
# Kernel dependencies # Kernel dependencies
, kernel ? null , kernel ? null
@ -18,6 +18,8 @@
with lib; with lib;
let let
smartmon = smartmontools.override { inherit enableMail; };
buildKernel = any (n: n == configFile) [ "kernel" "all" ]; buildKernel = any (n: n == configFile) [ "kernel" "all" ];
buildUser = any (n: n == configFile) [ "user" "all" ]; buildUser = any (n: n == configFile) [ "user" "all" ];
@ -148,7 +150,7 @@ let
''; '';
postFixup = 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 '' in ''
for i in $out/libexec/zfs/zpool.d/*; do for i in $out/libexec/zfs/zpool.d/*; do
sed -i '2i${path}' $i sed -i '2i${path}' $i
@ -157,12 +159,17 @@ let
outputs = [ "out" ] ++ optionals buildUser [ "lib" "dev" ]; outputs = [ "out" ] ++ optionals buildUser [ "lib" "dev" ];
passthru.tests = if isUnstable then passthru = {
[ nixosTests.zfs.unstable ] inherit enableMail;
else [
nixosTests.zfs.installer tests =
nixosTests.zfs.stable if isUnstable then [
]; nixosTests.zfs.unstable
] else [
nixosTests.zfs.installer
nixosTests.zfs.stable
];
};
meta = { meta = {
description = "ZFS Filesystem Linux Kernel module"; description = "ZFS Filesystem Linux Kernel module";

View File

@ -1,5 +1,6 @@
{ lib, stdenv, fetchurl, autoreconfHook { lib, stdenv, fetchurl, autoreconfHook
, mailutils, inetutils , mailutils, enableMail ? true
, inetutils
, IOKit, ApplicationServices }: , IOKit, ApplicationServices }:
let let
@ -26,7 +27,7 @@ in stdenv.mkDerivation rec {
postPatch = "cp -v ${driverdb} drivedb.h"; postPatch = "cp -v ${driverdb} drivedb.h";
configureFlags = [ configureFlags = [
"--with-scriptpath=${lib.makeBinPath [ mailutils inetutils ]}" "--with-scriptpath=${lib.makeBinPath ([ inetutils ] ++ lib.optional enableMail mailutils)}"
]; ];
nativeBuildInputs = [ autoreconfHook ]; nativeBuildInputs = [ autoreconfHook ];