summary refs log tree commit diff
path: root/nixos/tests/redis.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/tests/redis.nix')
-rw-r--r--nixos/tests/redis.nix28
1 files changed, 24 insertions, 4 deletions
diff --git a/nixos/tests/redis.nix b/nixos/tests/redis.nix
index 529965d7acd..28b6058c2c0 100644
--- a/nixos/tests/redis.nix
+++ b/nixos/tests/redis.nix
@@ -1,6 +1,10 @@
-import ./make-test-python.nix ({ pkgs, ...} : {
+import ./make-test-python.nix ({ pkgs, ... }:
+let
+  redisSocket = "/run/redis/redis.sock";
+in
+{
   name = "redis";
-  meta = with pkgs.stdenv.lib.maintainers; {
+  meta = with pkgs.lib.maintainers; {
     maintainers = [ flokli ];
   };
 
@@ -10,7 +14,19 @@ import ./make-test-python.nix ({ pkgs, ...} : {
 
       {
         services.redis.enable = true;
-        services.redis.unixSocket = "/run/redis/redis.sock";
+        services.redis.unixSocket = redisSocket;
+
+        # Allow access to the unix socket for the "redis" group.
+        services.redis.unixSocketPerm = 770;
+
+        users.users."member" = {
+          createHome = false;
+          description = "A member of the redis group";
+          isNormalUser = true;
+          extraGroups = [
+            "redis"
+          ];
+        };
       };
   };
 
@@ -18,7 +34,11 @@ import ./make-test-python.nix ({ pkgs, ...} : {
     start_all()
     machine.wait_for_unit("redis")
     machine.wait_for_open_port("6379")
+
+    # The unix socket is accessible to the redis group
+    machine.succeed('su member -c "redis-cli ping | grep PONG"')
+
     machine.succeed("redis-cli ping | grep PONG")
-    machine.succeed("redis-cli -s /run/redis/redis.sock ping | grep PONG")
+    machine.succeed("redis-cli -s ${redisSocket} ping | grep PONG")
   '';
 })