{ pkgs, lib, config, ... }: let inherit (config.users) users; in { services.redis = { enable = true; unixSocket = "/run/redis/redis.socket"; databases = 16; syslog = true; extraConfig = '' bind 127.0.0.1 ::1 unixsocketperm 660 maxclients 1024 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 ''; }