]> Git — Sourcephile - sourcephile-nix.git/blob - hosts/losurdo/redis.nix
mermet: dovecot: fix virtual dirs
[sourcephile-nix.git] / hosts / losurdo / redis.nix
1 { pkgs, lib, config, ... }:
2 let
3 inherit (config.networking) hostName;
4 inherit (config.users) users;
5 in
6 {
7 fileSystems."/var/lib/redis" = {
8 device = "${hostName}/var/redis";
9 fsType = "zfs";
10 };
11
12 services.redis = {
13 enable = true;
14 unixSocket = "/run/redis/redis.socket";
15 databases = 16;
16 syslog = true;
17 bind = "127.0.0.1 ::1";
18 settings = {
19 unixsocketperm = "660";
20 maxclients = 1024;
21 maxmemory = "500mb";
22 maxmemory-policy = "volatile-ttl";
23 };
24 };
25
26 users.users.redis.group = "redis";
27 users.groups."redis" = {};
28
29 systemd.services.redis.serviceConfig = {
30 RuntimeDirectoryMode = "0750";
31 Group = users.redis.group;
32 };
33
34 # As suggested by redis in its logs
35 boot.kernel.sysctl."vm.overcommit_memory" = 1;
36 system.activationScripts.redis = ''
37 echo never >/sys/kernel/mm/transparent_hugepage/enabled
38 '';
39 }