]> Git — Sourcephile - sourcephile-nix.git/blob - hosts/losurdo/redis.nix
nix: update input flakes
[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 = lib.mkForce "660";
20 maxmemory = "500mb";
21 maxmemory-policy = "volatile-ttl";
22 };
23 };
24
25 users.users.redis.group = "redis";
26 users.groups."redis" = {};
27
28 systemd.services.redis.serviceConfig = {
29 RuntimeDirectoryMode = "0750";
30 Group = users.redis.group;
31 };
32
33 # As suggested by redis in its logs
34 boot.kernel.sysctl."vm.overcommit_memory" = 1;
35 system.activationScripts.redis = ''
36 echo never >/sys/kernel/mm/transparent_hugepage/enabled
37 '';
38 }