3 cfg = config.myServices.databases.redis;
5 options.myServices.databases.redis = {
6 enable = lib.mkOption {
9 description = "Whether to enable redis database";
10 type = lib.types.bool;
12 socketsDir = lib.mkOption {
13 type = lib.types.path;
14 default = "/run/redis";
16 The directory where Redis puts sockets.
20 systemdRuntimeDirectory = lib.mkOption {
22 # Use ReadWritePaths= instead if socketsDir is outside of /run
23 default = assert lib.strings.hasPrefix "/run/" cfg.socketsDir;
24 lib.strings.removePrefix "/run/" cfg.socketsDir;
26 Adjusted redis sockets directory for systemd
30 sockets = lib.mkOption {
31 type = lib.types.attrsOf lib.types.path;
33 redis = "${cfg.socketsDir}/redis.sock";
42 config = lib.mkIf cfg.enable {
43 users.users.redis.uid = config.ids.uids.redis;
44 users.groups.redis.gid = config.ids.gids.redis;
45 services.redis = rec {
48 unixSocket = cfg.sockets.redis;
54 systemd.services.redis.serviceConfig.RuntimeDirectory = cfg.systemdRuntimeDirectory;