about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVladimír Čunát <v@cunat.cz>2020-01-27 19:23:49 +0100
committerVladimír Čunát <v@cunat.cz>2020-01-31 15:22:52 +0100
commit02bf0557c0a91ff706cf15272db4a22344cbfb16 (patch)
treeb8d8d1cbcdabf108dd9e2590ca5d1e22ea6df16c
parentae74a0e27cab1034266bc868e889fcdffd23a188 (diff)
downloadnixlib-02bf0557c0a91ff706cf15272db4a22344cbfb16.tar
nixlib-02bf0557c0a91ff706cf15272db4a22344cbfb16.tar.gz
nixlib-02bf0557c0a91ff706cf15272db4a22344cbfb16.tar.bz2
nixlib-02bf0557c0a91ff706cf15272db4a22344cbfb16.tar.lz
nixlib-02bf0557c0a91ff706cf15272db4a22344cbfb16.tar.xz
nixlib-02bf0557c0a91ff706cf15272db4a22344cbfb16.tar.zst
nixlib-02bf0557c0a91ff706cf15272db4a22344cbfb16.zip
nixos/kresd: add .instances option
-rw-r--r--nixos/modules/services/networking/kresd.nix14
1 files changed, 12 insertions, 2 deletions
diff --git a/nixos/modules/services/networking/kresd.nix b/nixos/modules/services/networking/kresd.nix
index ce16b90b9cc1..a2f91a4200bf 100644
--- a/nixos/modules/services/networking/kresd.nix
+++ b/nixos/modules/services/networking/kresd.nix
@@ -96,6 +96,15 @@ in {
         For detailed syntax see ListenStream in man systemd.socket.
       '';
     };
+    instances = mkOption {
+      type = types.ints.unsigned;
+      default = 1;
+      description = ''
+        The number of instances to start.  They will be called kresd@{1,2,...}.service.
+        Knot Resolver uses no threads, so this is the way to scale.
+        You can dynamically start/stop them at will, so this is just system default.
+      '';
+    };
     # TODO: perhaps options for more common stuff like cache size or forwarding
   };
 
@@ -112,9 +121,10 @@ in {
 
     systemd.packages = [ package ]; # the units are patched inside the package a bit
 
-    systemd.targets.kresd = {
+    systemd.targets.kresd = { # configure units started by default
       wantedBy = [ "multi-user.target" ];
-      wants = [ "kres-cache-gc.service" "kresd@1.service" ];
+      wants = [ "kres-cache-gc.service" ]
+        ++ map (i: "kresd@${toString i}.service") (range 1 cfg.instances);
     };
     systemd.services."kresd@".serviceConfig = {
       ExecStart = "${package}/bin/kresd --noninteractive "