{ pkgs, lib, config, ... }: let inherit (config.networking) hostName; inherit (config.users) users; in { fileSystems."/var/lib/redis" = { device = "${hostName}/var/redis"; fsType = "zfs"; }; services.redis = { enable = true; unixSocket = "/run/redis/redis.socket"; databases = 16; syslog = true; bind = "127.0.0.1"; # ::1 settings = { unixsocketperm = lib.mkForce "660"; maxmemory = "500mb"; maxmemory-policy = "volatile-ttl"; }; }; users.users.redis.group = "redis"; users.groups."redis" = {}; systemd.services.redis.serviceConfig = { RuntimeDirectoryMode = "0750"; Group = users.redis.group; }; # As suggested by redis in its logs boot.kernel.sysctl."vm.overcommit_memory" = 1; system.activationScripts.redis = '' echo never >/sys/kernel/mm/transparent_hugepage/enabled ''; }