2021-01-25 08:26:54 +00:00
|
|
|
{ lib, fetchFromGitHub, buildGoPackage, makeWrapper, pythonPackages, pkg-config, systemd, hostname, extraTags ? [] }:
|
2018-05-05 12:44:36 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
# keep this in sync with github.com/DataDog/agent-payload dependency
|
2018-09-08 22:39:55 +01:00
|
|
|
payloadVersion = "4.7.1";
|
2019-06-27 18:52:16 +01:00
|
|
|
python = pythonPackages.python;
|
2018-05-05 12:44:36 +01:00
|
|
|
|
|
|
|
in buildGoPackage rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "datadog-agent";
|
2019-05-21 18:53:06 +01:00
|
|
|
version = "6.11.2";
|
2018-05-05 12:44:36 +01:00
|
|
|
owner = "DataDog";
|
|
|
|
repo = "datadog-agent";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
inherit owner repo;
|
2019-09-09 00:38:31 +01:00
|
|
|
rev = version;
|
2019-05-30 09:48:04 +01:00
|
|
|
sha256 = "1dwdiaf357l9c6b2cps5mdyfma3c1mp96zzxg1826fvz3x8ix68z";
|
2018-05-05 12:44:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
subPackages = [
|
|
|
|
"cmd/agent"
|
2019-03-01 07:21:10 +00:00
|
|
|
"cmd/cluster-agent"
|
2018-05-05 12:44:36 +01:00
|
|
|
"cmd/dogstatsd"
|
|
|
|
"cmd/py-launcher"
|
2019-03-01 07:21:10 +00:00
|
|
|
"cmd/trace-agent"
|
2018-05-05 12:44:36 +01:00
|
|
|
];
|
2019-04-19 08:09:54 +01:00
|
|
|
goDeps = ./datadog-agent-deps.nix;
|
2018-05-05 12:44:36 +01:00
|
|
|
goPackagePath = "github.com/${owner}/${repo}";
|
|
|
|
|
2018-08-09 14:33:22 +01:00
|
|
|
|
2021-01-17 03:51:22 +00:00
|
|
|
nativeBuildInputs = [ pkg-config makeWrapper ];
|
2018-09-08 22:39:55 +01:00
|
|
|
buildInputs = [ systemd ];
|
2018-05-05 12:44:36 +01:00
|
|
|
PKG_CONFIG_PATH = "${python}/lib/pkgconfig";
|
|
|
|
|
2018-09-08 22:39:55 +01:00
|
|
|
|
|
|
|
preBuild = let
|
2021-01-15 09:19:50 +00:00
|
|
|
ldFlags = lib.concatStringsSep " " [
|
2018-05-05 12:44:36 +01:00
|
|
|
"-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 22:39:55 +01: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 22:39:55 +01:00
|
|
|
'';
|
2018-05-05 12:44:36 +01:00
|
|
|
|
|
|
|
# DataDog use paths relative to the agent binary, so fix these.
|
|
|
|
postPatch = ''
|
2020-04-28 02:50:57 +01:00
|
|
|
sed -e "s|PyChecksPath =.*|PyChecksPath = \"$out/${python.sitePackages}\"|" \
|
|
|
|
-e "s|distPath =.*|distPath = \"$out/share/datadog-agent\"|" \
|
2018-05-05 12:44:36 +01:00
|
|
|
-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 12:44:36 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
# Install the config files and python modules from the "dist" dir
|
|
|
|
# into standard paths.
|
|
|
|
postInstall = ''
|
2020-04-28 02:50:57 +01:00
|
|
|
mkdir -p $out/${python.sitePackages} $out/share/datadog-agent
|
|
|
|
cp -R $src/cmd/agent/dist/conf.d $out/share/datadog-agent
|
|
|
|
cp -R $src/cmd/agent/dist/{checks,utils,config.py} $out/${python.sitePackages}
|
2018-05-05 12:44:36 +01:00
|
|
|
|
2020-04-28 02:50:57 +01:00
|
|
|
cp -R $src/pkg/status/dist/templates $out/share/datadog-agent
|
2018-05-05 12:44:36 +01:00
|
|
|
|
2020-04-28 02:50:57 +01:00
|
|
|
wrapProgram "$out/bin/agent" \
|
|
|
|
--set PYTHONPATH "$out/${python.sitePackages}" \
|
2020-08-12 19:20:51 +01:00
|
|
|
--prefix LD_LIBRARY_PATH : ${lib.getLib systemd}/lib
|
2018-05-05 12:44:36 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2018-05-05 12:44:36 +01:00
|
|
|
description = ''
|
|
|
|
Event collector for the DataDog analysis service
|
|
|
|
-- v6 new golang implementation.
|
|
|
|
'';
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://www.datadoghq.com";
|
2018-05-05 12:44:36 +01:00
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ thoughtpolice domenkozar rvl ];
|
|
|
|
};
|
|
|
|
}
|