Merge pull request #117456 from Izorkin/update-redis-options

nixos/redis: add option and change access to directories

Changed files
+18 -5
nixos
modules
services
databases
tests
+17 -4
nixos/modules/services/databases/redis.nix
···
example = "/run/redis/redis.sock";
};
+
unixSocketPerm = mkOption {
+
type = types.int;
+
default = 750;
+
description = "Change permissions for the socket";
+
example = 700;
+
};
+
logLevel = mkOption {
type = types.str;
default = "notice"; # debug, verbose, notice, warning
···
'';
example = literalExample ''
{
-
unixsocketperm = "700";
loadmodule = [ "/path/to/my_module.so" "/path/to/other_module.so" ];
}
'';
···
slowlog-max-len = cfg.slowLogMaxLen;
}
(mkIf (cfg.bind != null) { bind = cfg.bind; })
-
(mkIf (cfg.unixSocket != null) { unixsocket = cfg.unixSocket; })
+
(mkIf (cfg.unixSocket != null) { unixsocket = cfg.unixSocket; unixsocketperm = "${toString cfg.unixSocketPerm}"; })
(mkIf (cfg.slaveOf != null) { slaveof = "${cfg.slaveOf.ip} ${cfg.slaveOf.port}"; })
(mkIf (cfg.masterAuth != null) { masterauth = cfg.masterAuth; })
(mkIf (cfg.requirePass != null) { requirepass = cfg.requirePass; })
···
serviceConfig = {
ExecStart = "${cfg.package}/bin/redis-server /run/redis/redis.conf";
-
RuntimeDirectory = "redis";
-
StateDirectory = "redis";
Type = "notify";
+
# User and group
User = "redis";
Group = "redis";
+
# Runtime directory and mode
+
RuntimeDirectory = "redis";
+
RuntimeDirectoryMode = "0750";
+
# State directory and mode
+
StateDirectory = "redis";
+
StateDirectoryMode = "0700";
+
# Access write directories
+
UMask = "0077";
};
};
};
+1 -1
nixos/tests/redis.nix
···
services.redis.unixSocket = redisSocket;
# Allow access to the unix socket for the "redis" group.
-
services.redis.settings.unixsocketperm = "770";
+
services.redis.unixSocketPerm = 770;
users.users."member" = {
createHome = false;