From df6312e2cb842bbe1c612b33bac25f6c562e90cc Mon Sep 17 00:00:00 2001 From: Oliver Charles Date: Sun, 23 Jun 2013 19:07:41 +0100 Subject: [PATCH] memcached: Add more options and extraOptions support --- modules/services/databases/memcached.nix | 38 +++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/modules/services/databases/memcached.nix b/modules/services/databases/memcached.nix index f5f6be68f7f..a0e264f2299 100644 --- a/modules/services/databases/memcached.nix +++ b/modules/services/databases/memcached.nix @@ -30,6 +30,36 @@ in description = "The user to run Memcached as"; }; + listen = mkOption { + default = "127.0.0.1"; + description = "The IP address to bind to"; + }; + + port = mkOption { + default = 11211; + description = "The port to bind to"; + }; + + socket = mkOption { + default = ""; + description = "Unix socket path to listen on. Setting this will disable network support"; + example = "/var/run/memcached"; + }; + + maxMemory = mkOption { + default = 64; + description = "The maximum amount of memory to use for storage, in megabytes."; + }; + + maxConnections = mkOption { + default = 1024; + description = "The maximum number of simultaneous connections"; + }; + + extraOptions = mkOption { + default = []; + description = "A list of extra options that will be added as a suffix when running memcached"; + }; }; }; @@ -52,7 +82,13 @@ in after = [ "network.target" ]; serviceConfig = { - ExecStart = "${memcached}/bin/memcached"; + ExecStart = + let + networking = if cfg.socket != "" + then "-s ${cfg.socket}" + else "-l ${cfg.listen} -p ${toString cfg.port}"; + in "${memcached}/bin/memcached ${networking} -m ${toString cfg.maxMemory} -c ${toString cfg.maxConnections} ${concatStringsSep " " cfg.extraOptions}"; + User = cfg.user; }; };