1{ config, pkgs, ... }:
2let
3 pool = config.environment.variables.SNOWGLOBE_POOL;
4 image = "/var/cache/snowglobe/zfs/l2arc";
5 capacity = 150 * 1024 * 1024 * 1024;
6 headroom = 32 * 1024 * 1024 * 1024;
7in
8{
9 # Reclaim pressure otherwise shrinks the ARC to a few GiB with most memory free.
10 boot.kernelParams = [ "zfs.zfs_arc_min=${toString (32 * 1024 * 1024 * 1024)}" ];
11
12 systemd.services.snowglobe-zfs-read-cache = {
13 wantedBy = [ "multi-user.target" ];
14 after = [ "zfs-import-${pool}.service" ];
15 path = [ config.boot.zfs.package ];
16 serviceConfig = {
17 Type = "oneshot";
18 RemainAfterExit = true;
19 CacheDirectory = "snowglobe/zfs";
20 CacheDirectoryMode = "0700";
21 UMask = "0077";
22 TimeoutStartSec = "5min";
23 ExecStart = "${pkgs.python3}/bin/python3 ${../tools/zfs-read-cache.py} ${pool} ${image} ${toString capacity} ${toString headroom}";
24 };
25 };
26}