1 # The declarations in this file build the Datadog agent's core
2 # integrations. These integrations are tracked in a separate
3 # repository[1] outside of the agent's primary repository and provide
4 # checks for various kinds of services.
6 # Not all services are relevant for all users, however. As some of
7 # them depend on various tools and Python packages it is nonsensical
8 # to build *all* integrations by default.
10 # A set of default integrations is defined and built either way.
11 # Additional integrations can be specified by overriding
12 # `extraIntegrations` in datadog-integrations-core.
14 # In practice the syntax for using this with additional integrations
15 # is not the most beautiful, but it works. For example to use
16 # datadog-agent from the top-level with the `ntp`-integration
17 # included, one could say:
20 # integrationsWithNtp = datadog-integrations-core {
21 # # Extra integrations map from the integration name (as in the
22 # # integrations-core repository) to a function that receives the
23 # # Python package set and returns the required dependencies.g
24 # ntp = (ps: [ ps.ntplib ]);
27 # in ddAgentWithNtp = datadog-agent.overrideAttrs(_ : {
28 # python = integrationsWithNtp.python;
31 # The NixOS module 'datadog-agent' provides a simplified interface to
32 # this. Please see the module itself for more information.
34 # [1]: https://github.com/DataDog/integrations-core
36 { pkgs, python, extraIntegrations ? {} }:
39 inherit (pkgs.lib) attrValues mapAttrs;
41 src = pkgs.fetchFromGitHub {
43 repo = "integrations-core";
45 sha256 = "sha256-CIzuJ97KwsG1k65Y+8IUSka/3JX1pmQKN3hPHzZnGhQ=";
49 # Build helper to build a single datadog integration package.
50 buildIntegration = { pname, ... }@args: python.pkgs.buildPythonPackage (args // {
52 name = "datadog-integration-${pname}-${version}";
54 sourceRoot = "${src.name}/${args.sourceRoot or pname}";
58 # Base package depended on by all other integrations.
59 datadog_checks_base = buildIntegration {
60 pname = "checks-base";
61 sourceRoot = "datadog_checks_base";
63 # Make setuptools build the 'base' and 'checks' modules.
65 substituteInPlace setup.py \
66 --replace "from setuptools import setup" "from setuptools import find_packages, setup" \
67 --replace "packages=['datadog_checks']" "packages=find_packages()"
70 propagatedBuildInputs = with python.pkgs; [
89 pythonImportsCheck = [
91 "datadog_checks.base.checks"
92 "datadog_checks.checks"
96 # Default integrations that should be built:
97 defaultIntegrations = {
98 disk = (ps: [ ps.psutil ]);
99 mongo = (ps: [ ps.pymongo ]);
100 network = (ps: [ ps.psutil ]);
102 postgres = (ps: with ps; [ pg8000 psycopg2 semver ]);
103 process = (ps: [ ps.psutil]);
106 # All integrations (default + extra):
107 integrations = defaultIntegrations // extraIntegrations;
108 builtIntegrations = mapAttrs (pname: fdeps: buildIntegration {
110 propagatedBuildInputs = (fdeps python.pkgs) ++ [ datadog_checks_base ];
113 in builtIntegrations // {
114 inherit datadog_checks_base;
115 python = python.withPackages (_: (attrValues builtIntegrations));