summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/collectd.nix
diff options
context:
space:
mode:
authorAstro <astro@spaceboyz.net>2019-10-20 00:37:15 +0200
committerAstro <astro@spaceboyz.net>2019-10-20 00:53:49 +0200
commit06abd2488673f4563d5ae157f9167dd13a6ce469 (patch)
treeec3dcc36dcf422421cfd2d9a8b4aaa7af8fae98c /nixos/modules/services/monitoring/collectd.nix
parentefab03957535a1ed749bf286f78fad03e9b0f511 (diff)
downloadnixpkgs-06abd2488673f4563d5ae157f9167dd13a6ce469.tar
nixpkgs-06abd2488673f4563d5ae157f9167dd13a6ce469.tar.gz
nixpkgs-06abd2488673f4563d5ae157f9167dd13a6ce469.tar.bz2
nixpkgs-06abd2488673f4563d5ae157f9167dd13a6ce469.tar.lz
nixpkgs-06abd2488673f4563d5ae157f9167dd13a6ce469.tar.xz
nixpkgs-06abd2488673f4563d5ae157f9167dd13a6ce469.tar.zst
nixpkgs-06abd2488673f4563d5ae157f9167dd13a6ce469.zip
nixos/collectd: add option buildMinimalPackage
Diffstat (limited to 'nixos/modules/services/monitoring/collectd.nix')
-rw-r--r--nixos/modules/services/monitoring/collectd.nix21
1 files changed, 19 insertions, 2 deletions
diff --git a/nixos/modules/services/monitoring/collectd.nix b/nixos/modules/services/monitoring/collectd.nix
index 3d672613296..b2e44a1e366 100644
--- a/nixos/modules/services/monitoring/collectd.nix
+++ b/nixos/modules/services/monitoring/collectd.nix
@@ -30,6 +30,15 @@ let
     ${cfg.extraConfig}
   '';
 
+  package =
+    if cfg.buildMinimalPackage
+    then minimalPackage
+    else cfg.package;
+
+  minimalPackage = cfg.package.override {
+    enabledPlugins = [ "syslog" ] ++ builtins.attrNames cfg.plugins;
+  };
+
 in {
   options.services.collectd = with types; {
     enable = mkEnableOption "collectd agent";
@@ -40,7 +49,15 @@ in {
       description = ''
         Which collectd package to use.
       '';
-      type = package;
+      type = types.package;
+    };
+
+    buildMinimalPackage = mkOption {
+      default = false;
+      description = ''
+        Build a minimal collectd package with only the configured `services.collectd.plugins`
+      '';
+      type = types.bool;
     };
 
     user = mkOption {
@@ -105,7 +122,7 @@ in {
       wantedBy = [ "multi-user.target" ];
 
       serviceConfig = {
-        ExecStart = "${cfg.package}/sbin/collectd -C ${conf} -f";
+        ExecStart = "${package}/sbin/collectd -C ${conf} -f";
         User = cfg.user;
         Restart = "on-failure";
         RestartSec = 3;