aboutsummaryrefslogtreecommitdiff
path: root/modules/apps/memcached/instance.nix
blob: ca6dc3fdcc109c55c04eecfc65d0d034c73ac85b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
pkgs:
{ lib, name, ... }:

let

  inherit (builtins) match ;

  inherit (lib)
    mkOption mkOptionType ;

  inherit (lib.types)
    bool enum int listOf nullOr package path str submodule ;

  default = v: type: mkOption { type = type; default = v; };
  optional = type: mkOption { type = nullOr type; default = null; };

  isFloat = x: match "^[0-9]+(\\.[0-9]+)?$" (toString x) != null;

  float = mkOptionType {
    name = "positive float";
    check = isFloat;
  };

in {
  options = {

    user = mkOption {
      description = "User to run as";
      type = str;
      default = "memcached-${name}";
    };

    package = mkOption {
      description = "Memcached package";
      type = package;
      default = pkgs.memcached;
    };

    args = mkOption {
      description = "Memcached command line arguments. Refer to memcached man page.";
      default = {};
      type = submodule {
        options = {
          M = optional bool;
          R = optional int;
          B = optional (enum ["auto" "ascii" "binary"]);
          I = optional int;
          L = optional bool;
          l = default ["127.0.0.1"] (listOf str);
          b = optional int;
          c = optional int;
          f = optional float;
          p = default 11211 int;
          t = optional int;
          D = optional str;
          a = optional str;
          m = optional int;
          n = optional int;
          F = optional bool;
          U = default 11211 int;
          C = optional bool;
          k = optional bool;
          A = optional bool;
          S = optional bool;
          s = optional path;
        };
      };
    };
  };
}