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 ? {} }:
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 = "source/${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";
62 propagatedBuildInputs = with python.pkgs; [
81 # Default integrations that should be built:
82 defaultIntegrations = {
83 disk = (ps: [ ps.psutil ]);
84 mongo = (ps: [ ps.pymongo ]);
85 network = (ps: [ ps.psutil ]);
87 postgres = (ps: with ps; [ pg8000 psycopg2 semver ]);
88 process = (ps: [ ps.psutil]);
91 # All integrations (default + extra):
92 integrations = defaultIntegrations // extraIntegrations;
93 builtIntegrations = mapAttrs (pname: fdeps: buildIntegration {
95 propagatedBuildInputs = (fdeps python.pkgs) ++ [ datadog_checks_base ];
98 in builtIntegrations // {
99 inherit datadog_checks_base;
100 python = python.withPackages (_: (attrValues builtIntegrations));