2019-12-23 08:58:03 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, buildGoPackage, makeWrapper, pythonPackages, pkgconfig, systemd, hostname, extraTags ? [] }:
|
2018-05-05 11:44:36 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
# keep this in sync with github.com/DataDog/agent-payload dependency
|
2018-09-08 21:39:55 +00:00
|
|
|
payloadVersion = "4.7.1";
|
2019-06-27 17:52:16 +00:00
|
|
|
python = pythonPackages.python;
|
2018-05-05 11:44:36 +00:00
|
|
|
|
|
|
|
in buildGoPackage rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "datadog-agent";
|
2019-05-21 17:53:06 +00:00
|
|
|
version = "6.11.2";
|
2018-05-05 11:44:36 +00:00
|
|
|
owner = "DataDog";
|
|
|
|
repo = "datadog-agent";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
inherit owner repo;
|
2019-09-08 23:38:31 +00:00
|
|
|
rev = version;
|
2019-05-30 08:48:04 +00:00
|
|
|
sha256 = "1dwdiaf357l9c6b2cps5mdyfma3c1mp96zzxg1826fvz3x8ix68z";
|
2018-05-05 11:44:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
subPackages = [
|
|
|
|
"cmd/agent"
|
2019-03-01 07:21:10 +00:00
|
|
|
"cmd/cluster-agent"
|
2018-05-05 11:44:36 +00:00
|
|
|
"cmd/dogstatsd"
|
|
|
|
"cmd/py-launcher"
|
2019-03-01 07:21:10 +00:00
|
|
|
"cmd/trace-agent"
|
2018-05-05 11:44:36 +00:00
|
|
|
];
|
2019-04-19 07:09:54 +00:00
|
|
|
goDeps = ./datadog-agent-deps.nix;
|
2018-05-05 11:44:36 +00:00
|
|
|
goPackagePath = "github.com/${owner}/${repo}";
|
|
|
|
|
2018-08-09 13:33:22 +00:00
|
|
|
|
2018-05-05 11:44:36 +00:00
|
|
|
nativeBuildInputs = [ pkgconfig makeWrapper ];
|
2018-09-08 21:39:55 +00:00
|
|
|
buildInputs = [ systemd ];
|
2018-05-05 11:44:36 +00:00
|
|
|
PKG_CONFIG_PATH = "${python}/lib/pkgconfig";
|
|
|
|
|
2018-09-08 21:39:55 +00:00
|
|
|
|
|
|
|
preBuild = let
|
2018-05-05 11:44:36 +00:00
|
|
|
ldFlags = stdenv.lib.concatStringsSep " " [
|
|
|
|
"-X ${goPackagePath}/pkg/version.Commit=${src.rev}"
|
|
|
|
"-X ${goPackagePath}/pkg/version.AgentVersion=${version}"
|
|
|
|
"-X ${goPackagePath}/pkg/serializer.AgentPayloadVersion=${payloadVersion}"
|
|
|
|
"-X ${goPackagePath}/pkg/collector/py.pythonHome=${python}"
|
|
|
|
"-r ${python}/lib"
|
|
|
|
];
|
2018-09-08 21:39:55 +00:00
|
|
|
in ''
|
2019-12-23 08:58:03 +00:00
|
|
|
buildFlagsArray=( "-tags" "ec2 systemd cpython process log secrets ${lib.concatStringsSep " " extraTags}" "-ldflags" "${ldFlags}")
|
2018-09-08 21:39:55 +00:00
|
|
|
'';
|
2018-05-05 11:44:36 +00:00
|
|
|
|
|
|
|
# DataDog use paths relative to the agent binary, so fix these.
|
|
|
|
postPatch = ''
|
|
|
|
sed -e "s|PyChecksPath =.*|PyChecksPath = \"$bin/${python.sitePackages}\"|" \
|
|
|
|
-e "s|distPath =.*|distPath = \"$bin/share/datadog-agent\"|" \
|
|
|
|
-i cmd/agent/common/common_nix.go
|
2019-02-28 19:48:49 +00:00
|
|
|
sed -e "s|/bin/hostname|${lib.getBin hostname}/bin/hostname|" \
|
|
|
|
-i pkg/util/hostname_nix.go
|
2018-05-05 11:44:36 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# Install the config files and python modules from the "dist" dir
|
|
|
|
# into standard paths.
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $bin/${python.sitePackages} $bin/share/datadog-agent
|
2018-12-24 11:16:22 +00:00
|
|
|
cp -R $src/cmd/agent/dist/conf.d $bin/share/datadog-agent
|
2018-05-05 11:44:36 +00:00
|
|
|
cp -R $src/cmd/agent/dist/{checks,utils,config.py} $bin/${python.sitePackages}
|
|
|
|
|
|
|
|
cp -R $src/pkg/status/dist/templates $bin/share/datadog-agent
|
|
|
|
|
|
|
|
wrapProgram "$bin/bin/agent" \
|
2018-09-13 08:11:41 +00:00
|
|
|
--set PYTHONPATH "$bin/${python.sitePackages}" \
|
|
|
|
--prefix LD_LIBRARY_PATH : ${systemd.lib}/lib
|
2018-05-05 11:44:36 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = ''
|
|
|
|
Event collector for the DataDog analysis service
|
|
|
|
-- v6 new golang implementation.
|
|
|
|
'';
|
|
|
|
homepage = https://www.datadoghq.com;
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = platforms.all;
|
|
|
|
maintainers = with maintainers; [ thoughtpolice domenkozar rvl ];
|
|
|
|
};
|
|
|
|
}
|