1 { lib, config, pkgs, ... }:
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 sockets = lib.mkOption {
21 type = lib.types.attrsOf lib.types.path;
23 redis = "${cfg.socketsDir}/redis.sock";
32 config = lib.mkIf cfg.enable {
33 users.users.redis.uid = config.ids.uids.redis;
34 users.groups.redis.gid = config.ids.gids.redis;
35 services.redis.servers."" = {
38 unixSocket = cfg.sockets.redis;
42 systemd.services.redis.serviceConfig.Slice = "redis.slice";
43 systemd.services.redis.serviceConfig.RuntimeDirectoryMode = lib.mkForce "0755";
44 services.redis.servers."php-sessions" = {
55 source = "0.0.0.0:16379";
56 target = "/run/redis/redis.sock";
57 keyfile = config.secrets.fullPaths."redis/spiped_keyfile";
60 systemd.services.spiped_redis = {
61 description = "Secure pipe 'redis'";
62 after = [ "network.target" ];
63 wantedBy = [ "multi-user.target" ];
66 Slice = "redis.slice";
69 PermissionsStartOnly = true;
70 SupplementaryGroups = "keys";
73 script = "exec ${pkgs.spiped}/bin/spiped -F `cat /etc/spiped/redis.spec`";
76 #services.filesWatcher.predixy = {
78 # paths = [ config.secrets.fullPaths."redis/predixy.conf" ];
81 networking.firewall.allowedTCPPorts = [ 16379 ];
83 #"redis/predixy.conf" = {
86 # permissions = "0400";
94 # Auth "${config.myEnv.databases.redis.predixy.read}" {
99 # StandaloneServerPool {
101 # RefreshMethod fixed
103 # + ${config.myEnv.databases.redis.socket}
108 "redis/spiped_keyfile" = {
111 permissions = "0400";
112 text = config.myEnv.databases.redis.spiped_key;
116 systemd.slices.redis = {
117 description = "Redis slice";
120 #systemd.services.predixy = {
121 # description = "Redis proxy";
122 # wantedBy = [ "multi-user.target" ];
123 # after = [ "redis.service" ];
126 # Slice = "redis.slice";
129 # SupplementaryGroups = "keys";
132 # ExecStart = "${pkgs.predixy}/bin/predixy ${config.secrets.fullPaths."redis/predixy.conf"}";