{ config, service_configs, pkgs, ... }: { boot.zfs.package = pkgs.zfs; boot.initrd.kernelModules = [ "zfs" ]; boot.kernelParams = let # SEE: https://github.com/openzfs/zfs/pull/15437 # and https://blog.thalheim.io/2025/10/17/zfs-ate-my-ram-understanding-the-arc-cache/ arc_max_gb = (service_configs.gb_ram * 5) / 8; arc_max_mb = arc_max_gb * 1000; arc_max_kb = arc_max_mb * 1000; arc_max_b = arc_max_kb * 1000; arc_min_gb = 4; arc_min_mb = arc_min_gb * 1000; arc_min_kb = arc_min_mb * 1000; arc_min_b = arc_min_kb * 1000; in [ "zfs.zfs_arc_max=${builtins.toString arc_max_b}" "zfs.zfs_arc_min=${builtins.toString arc_min_b}" "zfs.zfs_txg_timeout=120" # longer TXG open time = larger sequential writes ]; 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; }; }