diff --git a/nixos/modules/services/monitoring/collectd.nix b/nixos/modules/services/monitoring/collectd.nix index fc97d4f63e6c..a80f7dfafaa8 100644 --- a/nixos/modules/services/monitoring/collectd.nix +++ b/nixos/modules/services/monitoring/collectd.nix @@ -46,6 +46,20 @@ in package = lib.mkPackageOption pkgs "collectd" { }; + finalPackage = lib.mkOption { + readOnly = true; + default = minimalPackage; + defaultText = lib.literalExpression '' + if config.services.collectd.buildMinimalPackage then + cfg.package.override { + enabledPlugins = [ "syslog" ] ++ builtins.attrNames cfg.plugins; + } + else + cfg.package + ''; + description = "The final package being used after applying plugins and minimalPackage."; + }; + buildMinimalPackage = lib.mkOption { default = false; description = '' diff --git a/pkgs/tools/system/collectd/default.nix b/pkgs/tools/system/collectd/default.nix index 86b5b8415753..f9359ae08dc7 100644 --- a/pkgs/tools/system/collectd/default.nix +++ b/pkgs/tools/system/collectd/default.nix @@ -11,10 +11,10 @@ flex, perl, nixosTests, - ... -}@args: + enabledPlugins ? null, +}: let - plugins = callPackage ./plugins.nix args; + plugins = callPackage ./plugins.nix { inherit enabledPlugins; }; in stdenv.mkDerivation (finalAttrs: { pname = "collectd"; diff --git a/pkgs/tools/system/collectd/plugins.nix b/pkgs/tools/system/collectd/plugins.nix index 2f8ba6c56b42..b871112d14bf 100644 --- a/pkgs/tools/system/collectd/plugins.nix +++ b/pkgs/tools/system/collectd/plugins.nix @@ -45,7 +45,6 @@ # Defaults to `null` for all supported plugins (except xen, which is marked as # insecure), otherwise a list of plugin names for a custom build enabledPlugins ? null, - ... }: let