1 { pkgs, lib, hostName, ... }:
3 # none is the recommended elevator with ZFS (which has its own I/O scheduler)
4 # and/or for SSD, whereas HDD could use mq-deadline.
5 services.udev.extraRules = ''
6 ACTION=="add|change", KERNEL=="sd[a-z]*[0-9]*|mmcblk[0-9]*p[0-9]*|nvme[0-9]*n[0-9]*p[0-9]*", ENV{ID_FS_TYPE}=="zfs_member", ATTR{../queue/scheduler}="none"
7 ACTION=="add|change", KERNEL=="sd[a-z][0-9]*", ATTR{../queue/rotational}=="0", ATTR{../queue/scheduler}="none"
8 ACTION=="add|change", KERNEL=="nvme[0-9]*n[0-9]*p[0-9]*", ATTR{../queue/rotational}=="0", ATTR{../queue/scheduler}="none"
11 boot.supportedFilesystems = [ "zfs" ];
12 boot.initrd.supportedFilesystems = [ "zfs" ];
14 # Using ZFS together with hibernation (suspend to disk)
15 # may cause filesystem corruption.
16 # See https://github.com/openzfs/zfs/issues/260
17 boot.kernelParams = [ "nohibernate" ];
19 # Stable enough, clearer, and faster than the default /dev/disk/by-id
20 boot.zfs.devNodes = "/dev/disk/by-partlabel";
22 boot.zfs.forceImportAll = false;
23 # More resilient for remote hosts,
24 # though it may call zpool clear.
25 boot.zfs.forceImportRoot = true;
26 boot.zfs.requestEncryptionCredentials = lib.mkDefault [ "${hostName}/root" ];
28 boot.zfs.enableUnstable = false;
30 # Enables periodic scrubbing of ZFS pools.
31 services.zfs.autoScrub.enable = true;
32 services.zfs.autoScrub.interval = "Sun *-*-08..14 00:15:00";
34 # According to zpool(8), for consumer hardware
35 # periodic manual TRIM is preferred over the automatic TRIM
36 # that ZFS implements.
37 services.zfs.trim.enable = true;
38 services.zfs.trim.interval = "Sun *-*-01..07 00:15:00";
40 environment.systemPackages = [
41 pkgs.lzop # For remote syncoid
42 pkgs.mbuffer # For remote syncoid