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