Merge pull request #72734 from nyanloutre/zfs_zed_config_module

nixos/zfs: ZED config module

authored by Silvan Mosberger and committed by GitHub 89b1bd1b 769f4308

+64 -2
+64 -2
nixos/modules/tasks/filesystems/zfs.nix
··· 12 12 cfgSnapFlags = cfgSnapshots.flags; 13 13 cfgScrub = config.services.zfs.autoScrub; 14 14 cfgTrim = config.services.zfs.trim; 15 + cfgZED = config.services.zfs.zed; 15 16 16 17 inInitrd = any (fs: fs == "zfs") config.boot.initrd.supportedFilesystems; 17 18 inSystem = any (fs: fs == "zfs") config.boot.supportedFilesystems; ··· 87 88 } 88 89 ''; 89 90 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; 90 102 in 91 103 92 104 { ··· 312 324 ''; 313 325 }; 314 326 }; 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 + }; 315 353 }; 316 354 317 355 ###### implementation ··· 389 427 zfsSupport = true; 390 428 }; 391 429 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 + }; 394 456 395 457 system.fsPackages = [ packages.zfsUser ]; # XXX: needed? zfs doesn't have (need) a fsck 396 458 environment.systemPackages = [ packages.zfsUser ]