git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #109345 from cole-h/zfs-closure

Shrink the ZFS closure by making mail support optional

commite4cf0e7a45cc32c1f37a3c58e13440f4281fef91 authorLinus Heckemann <git@sphalerite.org> dateWed 10 Feb 2021, 23:04 (6 years ago) parent0f1cfb21ed5b6a
3 files changed+55−33
nixos/modules/tasks/filesystems/zfs.nix+36−22 pkgs/os-specific/linux/zfs/default.nix+16−9 pkgs/tools/system/smartmontools/default.nix+3−2
nixos/modules/tasks/filesystems/zfs.nix+36−22
@@ -326,30 +326,36 @@ in
326326 };
327327 };
328328
329− services.zfs.zed.settings = mkOption {
330− type = with types; attrsOf (oneOf [ str int bool (listOf str) ]);
331− example = literalExample ''
332− {
333− ZED_DEBUG_LOG = "/tmp/zed.debug.log";
329+ services.zfs.zed = {
330+ enableMail = mkEnableOption "ZED's ability to send emails" // {
331+ default = cfgZfs.package.enableMail;
332+ };
334333
335− ZED_EMAIL_ADDR = [ "root" ];
336− ZED_EMAIL_PROG = "mail";
337− ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@";
334+ settings = mkOption {
335+ type = with types; attrsOf (oneOf [ str int bool (listOf str) ]);
336+ example = literalExample ''
337+ {
338+ ZED_DEBUG_LOG = "/tmp/zed.debug.log";
338339
339− ZED_NOTIFY_INTERVAL_SECS = 3600;
340− ZED_NOTIFY_VERBOSE = false;
340+ ZED_EMAIL_ADDR = [ "root" ];
341+ ZED_EMAIL_PROG = "mail";
342+ ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@";
341343
342− ZED_USE_ENCLOSURE_LEDS = true;
343− ZED_SCRUB_AFTER_RESILVER = false;
344− }
345− '';
346− description = ''
347− ZFS Event Daemon /etc/zfs/zed.d/zed.rc content
348−
349− See
350− <citerefentry><refentrytitle>zed</refentrytitle><manvolnum>8</manvolnum></citerefentry>
351− for details on ZED and the scripts in /etc/zfs/zed.d to find the possible variables
352− '';
344+ ZED_NOTIFY_INTERVAL_SECS = 3600;
345+ ZED_NOTIFY_VERBOSE = false;
346+
347+ ZED_USE_ENCLOSURE_LEDS = true;
348+ ZED_SCRUB_AFTER_RESILVER = false;
349+ }
350+ '';
351+ description = ''
352+ ZFS Event Daemon /etc/zfs/zed.d/zed.rc content
353+
354+ See
355+ <citerefentry><refentrytitle>zed</refentrytitle><manvolnum>8</manvolnum></citerefentry>
356+ for details on ZED and the scripts in /etc/zfs/zed.d to find the possible variables
357+ '';
358+ };
353359 };
354360 };
355361
@@ -358,6 +364,14 @@ in
358364 config = mkMerge [
359365 (mkIf cfgZfs.enabled {
360366 assertions = [
367+ {
368+ assertion = cfgZED.enableMail -> cfgZfs.package.enableMail;
369+ message = ''
370+ To allow ZED to send emails, ZFS needs to be configured to enable
371+ this. To do so, one must override the `zfs` package and set
372+ `enableMail` to true.
373+ '';
374+ }
361375 {
362376 assertion = config.networking.hostId != null;
363377 message = "ZFS requires networking.hostId to be set";
@@ -437,7 +451,7 @@ in
437451 };
438452
439453 services.zfs.zed.settings = {
440− ZED_EMAIL_PROG = mkDefault "${pkgs.mailutils}/bin/mail";
454+ ZED_EMAIL_PROG = mkIf cfgZED.enableMail (mkDefault "${pkgs.mailutils}/bin/mail");
441455 PATH = lib.makeBinPath [
442456 cfgZfs.package
443457 pkgs.coreutils
pkgs/os-specific/linux/zfs/default.nix+16−9
@@ -8,8 +8,8 @@
88, libtirpc
99, nfs-utils
1010, gawk, gnugrep, gnused, systemd
11−, smartmontools, sysstat, sudo
12−, pkg-config
11+, smartmontools, enableMail ? false
12+, sysstat, sudo, pkg-config
1313
1414# Kernel dependencies
1515, kernel ? null
@@ -18,6 +18,8 @@
1818
1919with lib;
2020let
21+ smartmon = smartmontools.override { inherit enableMail; };
22+
2123 buildKernel = any (n: n == configFile) [ "kernel" "all" ];
2224 buildUser = any (n: n == configFile) [ "user" "all" ];
2325
@@ -148,7 +150,7 @@ let
148150 '';
149151
150152 postFixup = let
151− path = "PATH=${makeBinPath [ coreutils gawk gnused gnugrep util-linux smartmontools sysstat ]}:$PATH";
153+ path = "PATH=${makeBinPath [ coreutils gawk gnused gnugrep util-linux smartmon sysstat ]}:$PATH";
152154 in ''
153155 for i in $out/libexec/zfs/zpool.d/*; do
154156 sed -i '2i${path}' $i
@@ -157,12 +159,17 @@ let
157159
158160 outputs = [ "out" ] ++ optionals buildUser [ "lib" "dev" ];
159161
160− passthru.tests = if isUnstable then
161− [ nixosTests.zfs.unstable ]
162− else [
163− nixosTests.zfs.installer
164− nixosTests.zfs.stable
165− ];
162+ passthru = {
163+ inherit enableMail;
164+
165+ tests =
166+ if isUnstable then [
167+ nixosTests.zfs.unstable
168+ ] else [
169+ nixosTests.zfs.installer
170+ nixosTests.zfs.stable
171+ ];
172+ };
166173
167174 meta = {
168175 description = "ZFS Filesystem Linux Kernel module";
pkgs/tools/system/smartmontools/default.nix+3−2
@@ -1,5 +1,6 @@
11{ lib, stdenv, fetchurl, autoreconfHook
2−, mailutils, inetutils
2+, mailutils, enableMail ? true
3+, inetutils
34, IOKit, ApplicationServices }:
45
56let
@@ -26,7 +27,7 @@ in stdenv.mkDerivation rec {
2627 postPatch = "cp -v ${driverdb} drivedb.h";
2728
2829 configureFlags = [
29− "--with-scriptpath=${lib.makeBinPath [ mailutils inetutils ]}"
30+ "--with-scriptpath=${lib.makeBinPath ([ inetutils ] ++ lib.optional enableMail mailutils)}"
3031 ];
3132
3233 nativeBuildInputs = [ autoreconfHook ];