1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
{ lib
, stdenv
, cmake
, buildGoModule
, makeWrapper
, fetchFromGitHub
, pythonPackages
, pkg-config
, systemd
, hostname
, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, extraTags ? [ ]
, testers
, datadog-agent
}:
let
# keep this in sync with github.com/DataDog/agent-payload dependency
payloadVersion = "5.0.97";
python = pythonPackages.python;
owner = "DataDog";
repo = "datadog-agent";
goPackagePath = "github.com/${owner}/${repo}";
version = "7.48.1";
src = fetchFromGitHub {
inherit owner repo;
rev = version;
hash = "sha256-3PFplTR/L2xJjQ5GEz2ow28SEHWafOmiLjIQHQqAaso=";
};
rtloader = stdenv.mkDerivation {
pname = "datadog-agent-rtloader";
src = "${src}/rtloader";
inherit version;
nativeBuildInputs = [ cmake ];
buildInputs = [ python ];
cmakeFlags = ["-DBUILD_DEMO=OFF" "-DDISABLE_PYTHON2=ON"];
};
in buildGoModule rec {
pname = "datadog-agent";
inherit src version;
doCheck = false;
vendorHash = "sha256-o7CTw7IIS5xueW20O1wKDV1Yji7PhGhp+6+i2ymKhxE=";
subPackages = [
"cmd/agent"
"cmd/cluster-agent"
"cmd/dogstatsd"
"cmd/py-launcher"
"cmd/trace-agent"
];
nativeBuildInputs = [ pkg-config makeWrapper ];
buildInputs = [rtloader] ++ lib.optionals withSystemd [ systemd ];
PKG_CONFIG_PATH = "${python}/lib/pkgconfig";
tags = [
"ec2"
"python"
"process"
"log"
"secrets"
"zlib"
]
++ lib.optionals withSystemd [ "systemd" ]
++ extraTags;
ldflags = [
"-X ${goPackagePath}/pkg/version.Commit=${src.rev}"
"-X ${goPackagePath}/pkg/version.AgentVersion=${version}"
"-X ${goPackagePath}/pkg/serializer.AgentPayloadVersion=${payloadVersion}"
"-X ${goPackagePath}/pkg/collector/python.pythonHome3=${python}"
"-X ${goPackagePath}/pkg/config.DefaultPython=3"
"-r ${python}/lib"
];
preBuild = ''
# Keep directories to generate in sync with tasks/go.py
go generate ./pkg/status ./cmd/agent/gui
'';
# DataDog use paths relative to the agent binary, so fix these.
postPatch = ''
sed -e "s|PyChecksPath =.*|PyChecksPath = \"$out/${python.sitePackages}\"|" \
-e "s|distPath =.*|distPath = \"$out/share/datadog-agent\"|" \
-i cmd/agent/common/path/path_nix.go
sed -e "s|/bin/hostname|${lib.getBin hostname}/bin/hostname|" \
-i pkg/util/hostname/fqdn_nix.go
'';
# Install the config files and python modules from the "dist" dir
# into standard paths.
postInstall = ''
mkdir -p $out/${python.sitePackages} $out/share/datadog-agent
cp -R --no-preserve=mode $src/cmd/agent/dist/conf.d $out/share/datadog-agent
rm -rf $out/share/datadog-agent/conf.d/{apm.yaml.default,process_agent.yaml.default,winproc.d}
cp -R $src/cmd/agent/dist/{checks,utils,config.py} $out/${python.sitePackages}
cp -R $src/pkg/status/templates $out/share/datadog-agent
wrapProgram "$out/bin/agent" \
--set PYTHONPATH "$out/${python.sitePackages}"'' + lib.optionalString withSystemd '' \
--prefix LD_LIBRARY_PATH : '' + lib.makeLibraryPath [ (lib.getLib systemd) rtloader ];
passthru.tests.version = testers.testVersion {
package = datadog-agent;
command = "agent version";
};
meta = with lib; {
description = ''
Event collector for the DataDog analysis service
-- v6 new golang implementation.
'';
homepage = "https://www.datadoghq.com";
license = licenses.bsd3;
maintainers = with maintainers; [ thoughtpolice domenkozar rvl viraptor ];
# never built on aarch64-darwin since first introduction in nixpkgs
broken = stdenv.isDarwin && stdenv.isAarch64;
};
}
|