{ config, service_configs, pkgs, ... }: { boot.zfs.package = pkgs.zfs; boot.initrd.kernelModules = [ "zfs" ]; boot.kernelParams = let arc_gb = 32; arc_mb = arc_gb * 1000; arc_kb = arc_mb * 1000; arc_b = arc_kb * 1000; dirty_gb = 8; # Default value is 4GB, helps smooth writes dirty_mb = dirty_gb * 1000; dirty_kb = dirty_mb * 1000; dirty_b = dirty_kb * 1000; in [ "zfs.zfs_arc_max=${builtins.toString arc_b}" "zfs.zfs_txg_timeout=120" # longer TXG open time = larger sequential writes "zfs.zfs_dirty_data_max=${builtins.toString dirty_b}" "zfs.zfs_delay_min_dirty_percent=80" # delay write throttling until 80% dirty (default 60%) "zfs.zfs_vdev_async_write_max_active=30" # more concurrent async writes to vdevs (default 10) ]; boot.supportedFilesystems = [ "zfs" ]; boot.zfs.extraPools = [ service_configs.zpool_ssds service_configs.zpool_hdds ]; services.sanoid = { enable = true; datasets."${service_configs.zpool_ssds}" = { recursive = true; autoprune = true; autosnap = true; hourly = 5; daily = 7; monthly = 3; yearly = 0; }; datasets."${service_configs.zpool_ssds}/services/sql" = { recursive = true; autoprune = true; autosnap = true; hourly = 12; daily = 2; monthly = 0; yearly = 0; }; datasets."${service_configs.zpool_ssds}/services/jellyfin/cache" = { recursive = true; autoprune = true; autosnap = true; hourly = 0; daily = 0; monthly = 0; yearly = 0; }; datasets."${service_configs.zpool_hdds}" = { recursive = true; autoprune = true; autosnap = true; hourly = 0; daily = 0; monthly = 0; yearly = 0; }; }; services.zfs = { autoScrub.enable = true; trim.enable = true; }; }