git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/zfs: Adding ZED configuration options

Co-authored-by: sjau <github.com@sjau.ch>

commitc082e13ecbed622f6b2f967716ea7d526a693197 authornyanloutre <paul@nyanlout.re> dateWed 4 Dec 2019, 20:29 (7 years ago) parent471869c
1 file changed+64−2
nixos/modules/tasks/filesystems/zfs.nix+64−2
nixos/modules/tasks/filesystems/zfs.nix+64−2
@@ -12,6 +12,7 @@ let
1212 cfgSnapFlags = cfgSnapshots.flags;
1313 cfgScrub = config.services.zfs.autoScrub;
1414 cfgTrim = config.services.zfs.trim;
15+ cfgZED = config.services.zfs.zed;
1516
1617 inInitrd = any (fs: fs == "zfs") config.boot.initrd.supportedFilesystems;
1718 inSystem = any (fs: fs == "zfs") config.boot.supportedFilesystems;
@@ -87,6 +88,17 @@ let
8788 }
8889 '';
8990
91+ zedConf = generators.toKeyValue {
92+ mkKeyValue = generators.mkKeyValueDefault {
93+ mkValueString = v:
94+ if isInt v then toString v
95+ else if isString v then "\"${v}\""
96+ else if true == v then "1"
97+ else if false == v then "0"
98+ else if isList v then "\"" + (concatStringsSep " " v) + "\""
99+ else err "this value is" (toString v);
100+ } "=";
101+ } cfgZED.settings;
90102in
91103
92104{
@@ -312,6 +324,32 @@ in
312324 '';
313325 };
314326 };
327+
328+ services.zfs.zed.settings = mkOption {
329+ type = with types; attrsOf (oneOf [ str int bool (listOf str) ]);
330+ example = literalExample ''
331+ {
332+ ZED_DEBUG_LOG = "/tmp/zed.debug.log";
333+
334+ ZED_EMAIL_ADDR = [ "root" ];
335+ ZED_EMAIL_PROG = "mail";
336+ ZED_EMAIL_OPTS = "-s '@SUBJECT@' @ADDRESS@";
337+
338+ ZED_NOTIFY_INTERVAL_SECS = 3600;
339+ ZED_NOTIFY_VERBOSE = false;
340+
341+ ZED_USE_ENCLOSURE_LEDS = true;
342+ ZED_SCRUB_AFTER_RESILVER = false;
343+ }
344+ '';
345+ description = ''
346+ ZFS Event Daemon /etc/zfs/zed.d/zed.rc content
347+
348+ See
349+ <citerefentry><refentrytitle>zed</refentrytitle><manvolnum>8</manvolnum></citerefentry>
350+ for details on ZED and the scripts in /etc/zfs/zed.d to find the possible variables
351+ '';
352+ };
315353 };
316354
317355 ###### implementation
@@ -389,8 +427,32 @@ in
389427 zfsSupport = true;
390428 };
391429
392− environment.etc."zfs/zed.d".source = "${packages.zfsUser}/etc/zfs/zed.d/";
393− environment.etc."zfs/zpool.d".source = "${packages.zfsUser}/etc/zfs/zpool.d/";
430+ services.zfs.zed.settings = {
431+ ZED_EMAIL_PROG = mkDefault "${pkgs.mailutils}/bin/mail";
432+ };
433+
434+ environment.etc = genAttrs
435+ (map
436+ (file: "zfs/zed.d/${file}")
437+ [
438+ "all-syslog.sh"
439+ "pool_import-led.sh"
440+ "resilver_finish-start-scrub.sh"
441+ "statechange-led.sh"
442+ "vdev_attach-led.sh"
443+ "zed-functions.sh"
444+ "data-notify.sh"
445+ "resilver_finish-notify.sh"
446+ "scrub_finish-notify.sh"
447+ "statechange-notify.sh"
448+ "vdev_clear-led.sh"
449+ ]
450+ )
451+ (file: { source = "${packages.zfsUser}/etc/${file}"; })
452+ // {
453+ "zfs/zed.d/zed.rc".text = zedConf;
454+ "zfs/zpool.d".source = "${packages.zfsUser}/etc/zfs/zpool.d/";
455+ };
394456
395457 system.fsPackages = [ packages.zfsUser ]; # XXX: needed? zfs doesn't have (need) a fsck
396458 environment.systemPackages = [ packages.zfsUser ]