From 370df31f1cacdac2f78072a30911fef7a81fb274 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Wed, 13 Jan 2021 23:38:19 -0800 Subject: [PATCH 1/3] nixos/zfs: make zed mail optional "zed does not need the ability to send email by default" --Eelco --- nixos/modules/tasks/filesystems/zfs.nix | 46 ++++++++++++++----------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix index b750820bfa50..f153cce4c726 100644 --- a/nixos/modules/tasks/filesystems/zfs.nix +++ b/nixos/modules/tasks/filesystems/zfs.nix @@ -326,30 +326,34 @@ 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"; - 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 - zed8 - 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 + zed8 + for details on ZED and the scripts in /etc/zfs/zed.d to find the possible variables + ''; + }; }; }; @@ -437,7 +441,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 From a206194b4ec06da05f08c9b02eab4f574498df6b Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Wed, 13 Jan 2021 23:40:08 -0800 Subject: [PATCH 2/3] smartmontools: make mail support optional It's enabled by default since that's how it was before this change. --- pkgs/tools/system/smartmontools/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/system/smartmontools/default.nix b/pkgs/tools/system/smartmontools/default.nix index 9eaf00b537a3..954c9eb4110c 100644 --- a/pkgs/tools/system/smartmontools/default.nix +++ b/pkgs/tools/system/smartmontools/default.nix @@ -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 ]; From 1ed5b6a285301a0ef17bbb8378ec43a6a79b3520 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Wed, 13 Jan 2021 23:40:46 -0800 Subject: [PATCH 3/3] zfs: disable smartmontools mail functionality --- nixos/modules/tasks/filesystems/zfs.nix | 12 +++++++++++- pkgs/os-specific/linux/zfs/default.nix | 25 ++++++++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix index f153cce4c726..59676e996785 100644 --- a/nixos/modules/tasks/filesystems/zfs.nix +++ b/nixos/modules/tasks/filesystems/zfs.nix @@ -327,7 +327,9 @@ in }; services.zfs.zed = { - enableMail = mkEnableOption "ZED's ability to send emails"; + enableMail = mkEnableOption "ZED's ability to send emails" // { + default = cfgZfs.package.enableMail; + }; settings = mkOption { type = with types; attrsOf (oneOf [ str int bool (listOf str) ]); @@ -362,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"; diff --git a/pkgs/os-specific/linux/zfs/default.nix b/pkgs/os-specific/linux/zfs/default.nix index a66520b6fa18..202dc9091fd5 100644 --- a/pkgs/os-specific/linux/zfs/default.nix +++ b/pkgs/os-specific/linux/zfs/default.nix @@ -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";