summary refs log tree commit diff
path: root/nixos/modules/services/databases/redis.nix
diff options
context:
space:
mode:
authorIzorkin <izorkin@elven.pw>2021-04-12 12:36:28 +0300
committerIzorkin <izorkin@elven.pw>2021-04-12 12:37:49 +0300
commite075aeb8c0113b3d91c63aa99b22dcb4ce5a0d81 (patch)
treeac150b9527523526fbe01322f92f4f38a4809dd4 /nixos/modules/services/databases/redis.nix
parent061c913c366b339fd28b741ca2f56dacb64497f8 (diff)
downloadnixpkgs-e075aeb8c0113b3d91c63aa99b22dcb4ce5a0d81.tar
nixpkgs-e075aeb8c0113b3d91c63aa99b22dcb4ce5a0d81.tar.gz
nixpkgs-e075aeb8c0113b3d91c63aa99b22dcb4ce5a0d81.tar.bz2
nixpkgs-e075aeb8c0113b3d91c63aa99b22dcb4ce5a0d81.tar.lz
nixpkgs-e075aeb8c0113b3d91c63aa99b22dcb4ce5a0d81.tar.xz
nixpkgs-e075aeb8c0113b3d91c63aa99b22dcb4ce5a0d81.tar.zst
nixpkgs-e075aeb8c0113b3d91c63aa99b22dcb4ce5a0d81.zip
nixos/redis: add option maxclients
Diffstat (limited to 'nixos/modules/services/databases/redis.nix')
-rw-r--r--nixos/modules/services/databases/redis.nix15
1 files changed, 13 insertions, 2 deletions
diff --git a/nixos/modules/services/databases/redis.nix b/nixos/modules/services/databases/redis.nix
index 24fe4ab3cc2..7ec10c0eb5a 100644
--- a/nixos/modules/services/databases/redis.nix
+++ b/nixos/modules/services/databases/redis.nix
@@ -5,6 +5,8 @@ with lib;
 let
   cfg = config.services.redis;
 
+  ulimitNofile = cfg.maxclients + 32;
+
   mkValueString = value:
     if value == true then "yes"
     else if value == false then "no"
@@ -14,8 +16,8 @@ let
     listsAsDuplicateKeys = true;
     mkKeyValue = generators.mkKeyValueDefault { inherit mkValueString; } " ";
   } cfg.settings);
-in
-{
+
+in {
   imports = [
     (mkRemovedOptionModule [ "services" "redis" "user" ] "The redis module now is hardcoded to the redis user.")
     (mkRemovedOptionModule [ "services" "redis" "dbpath" ] "The redis module now uses /var/lib/redis as data directory.")
@@ -121,6 +123,12 @@ in
         description = "Set the number of databases.";
       };
 
+      maxclients = mkOption {
+        type = types.int;
+        default = 10000;
+        description = "Set the max number of connected clients at the same time.";
+      };
+
       save = mkOption {
         type = with types; listOf (listOf int);
         default = [ [900 1] [300 10] [60 10000] ];
@@ -253,6 +261,7 @@ in
         logfile = cfg.logfile;
         syslog-enabled = cfg.syslog;
         databases = cfg.databases;
+        maxclients = cfg.maxclients;
         save = map (d: "${toString (builtins.elemAt d 0)} ${toString (builtins.elemAt d 1)}") cfg.save;
         dbfilename = "dump.rdb";
         dir = "/var/lib/redis";
@@ -299,6 +308,8 @@ in
         CapabilityBoundingSet = "";
         # Security
         NoNewPrivileges = true;
+        # Process Properties
+        LimitNOFILE = "${toString ulimitNofile}";
         # Sandboxing
         ProtectSystem = "strict";
         ProtectHome = true;