about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorRok Garbas <rok@garbas.si>2015-11-27 21:36:47 +0100
committerRok Garbas <rok@garbas.si>2015-11-27 21:42:21 +0100
commit2de0dc1a185a2e36cc7c388852a98897f94e00cd (patch)
tree51f7fd3a0547f550dc45282070ab4ff7fbe70b50 /nixos
parentc6932509b881a12867b7e1897c6b69ee991e98bd (diff)
statsd: updated package and nixos service
* package statsd node packages separatly since they actually require
  nodejs-0.10 or nodejs-0.12 to work (which is ... well old)

* remove statsd packages and its backends from "global" node-packages.json.
  i did not rebuild it since for some reason npm2nix command fails. next time
  somebody will rerun npm2nix statsd packages are going to be removed.

* statsd service: backends are now provided as strings and not anymore as
  packages.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/monitoring/statsd.nix31
1 files changed, 24 insertions, 7 deletions
diff --git a/nixos/modules/services/monitoring/statsd.nix b/nixos/modules/services/monitoring/statsd.nix
index d9e0b83e2389f..39fabc27d6c8d 100644
--- a/nixos/modules/services/monitoring/statsd.nix
+++ b/nixos/modules/services/monitoring/statsd.nix
@@ -6,13 +6,21 @@ let
 
   cfg = config.services.statsd;
 
+  isBuiltinBackend = name:
+    builtins.elem name [ "graphite" "console" "repeater" ];
+
   configFile = pkgs.writeText "statsd.conf" ''
     {
       address: "${cfg.host}",
       port: "${toString cfg.port}",
       mgmt_address: "${cfg.mgmt_address}",
       mgmt_port: "${toString cfg.mgmt_port}",
-      backends: [${concatMapStringsSep "," (el: if (nixType el) == "string" then ''"./backends/${el}"'' else ''"${head el.names}"'') cfg.backends}],
+      backends: [${
+        concatMapStringsSep "," (name:
+          if (isBuiltinBackend name)
+          then ''"./backends/${name}"''
+          else ''"${name}"''
+        ) cfg.backends}],
       ${optionalString (cfg.graphiteHost!=null) ''graphiteHost: "${cfg.graphiteHost}",''}
       ${optionalString (cfg.graphitePort!=null) ''graphitePort: "${toString cfg.graphitePort}",''}
       console: {
@@ -66,9 +74,16 @@ in
 
     backends = mkOption {
       description = "List of backends statsd will use for data persistence";
-      default = ["graphite"];
-      example = ["graphite" pkgs.nodePackages."statsd-influxdb-backend"];
-      type = types.listOf (types.either types.str types.package);
+      default = [];
+      example = [
+        "graphite"
+        "console"
+        "repeater"
+        "statsd-librato-backend"
+        "stackdriver-statsd-backend"
+        "statsd-influxdb-backend"
+      ];
+      type = types.listOf types.str;
     };
 
     graphiteHost = mkOption {
@@ -105,15 +120,17 @@ in
       description = "Statsd Server";
       wantedBy = [ "multi-user.target" ];
       environment = {
-        NODE_PATH=concatMapStringsSep ":" (el: "${el}/lib/node_modules") (filter (el: (nixType el) != "string") cfg.backends);
+        NODE_PATH=concatMapStringsSep ":"
+          (pkg: "${builtins.getAttr pkg pkgs.statsd.nodePackages}/lib/node_modules")
+          (filter (name: !isBuiltinBackend name) cfg.backends);
       };
       serviceConfig = {
-        ExecStart = "${pkgs.nodePackages.statsd}/bin/statsd ${configFile}";
+        ExecStart = "${pkgs.statsd}/bin/statsd ${configFile}";
         User = "statsd";
       };
     };
 
-    environment.systemPackages = [pkgs.nodePackages.statsd];
+    environment.systemPackages = [ pkgs.statsd ];
 
   };