2021-09-07 23:19:17 +00:00
|
|
|
{ lib, buildGoModule, makeWrapper, fetchFromGitHub, pythonPackages, pkg-config, systemd, hostname, extraTags ? [] }:
|
2018-05-05 11:44:36 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
# keep this in sync with github.com/DataDog/agent-payload dependency
|
2021-08-29 02:37:58 +00:00
|
|
|
payloadVersion = "4.78.0";
|
2019-06-27 17:52:16 +00:00
|
|
|
python = pythonPackages.python;
|
2018-05-05 11:44:36 +00:00
|
|
|
owner = "DataDog";
|
|
|
|
repo = "datadog-agent";
|
2021-08-29 02:37:58 +00:00
|
|
|
goPackagePath = "github.com/${owner}/${repo}";
|
|
|
|
|
|
|
|
in buildGoModule rec {
|
|
|
|
pname = "datadog-agent";
|
2022-02-11 07:55:06 +00:00
|
|
|
version = "7.33.0";
|
2018-05-05 11:44:36 +00:00
|
|
|
|
2021-09-07 23:19:17 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
inherit owner repo;
|
2021-08-29 02:37:58 +00:00
|
|
|
rev = version;
|
2022-02-11 07:55:06 +00:00
|
|
|
sha256 = "sha256-8QwXJrhuONdmM0oneGip4BhYkfuaNoYQn+MjlIpCk98=";
|
2018-05-05 11:44:36 +00:00
|
|
|
};
|
|
|
|
|
2022-02-11 07:55:06 +00:00
|
|
|
vendorSha256 = "sha256-3caBX+Z1SbX0u5yfh/218HH2jEvKV1IM6fd3HkYHTGk=";
|
2021-08-29 02:37:58 +00:00
|
|
|
|
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
|
|
|
];
|
|
|
|
|
2018-08-09 13:33:22 +00:00
|
|
|
|
2021-09-07 23:19:17 +00:00
|
|
|
nativeBuildInputs = [ pkg-config 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
|
2021-01-15 09:19:50 +00:00
|
|
|
ldFlags = lib.concatStringsSep " " [
|
2018-05-05 11:44:36 +00: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 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}")
|
2021-09-07 23:19:17 +00:00
|
|
|
# Keep directories to generate in sync with tasks/go.py
|
|
|
|
go generate ./pkg/status ./cmd/agent/gui
|
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 = ''
|
2020-04-28 01:50:57 +00:00
|
|
|
sed -e "s|PyChecksPath =.*|PyChecksPath = \"$out/${python.sitePackages}\"|" \
|
|
|
|
-e "s|distPath =.*|distPath = \"$out/share/datadog-agent\"|" \
|
2018-05-05 11:44:36 +00: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 11:44:36 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# Install the config files and python modules from the "dist" dir
|
|
|
|
# into standard paths.
|
|
|
|
postInstall = ''
|
2020-04-28 01:50:57 +00: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 11:44:36 +00:00
|
|
|
|
2021-08-29 02:37:58 +00:00
|
|
|
cp -R $src/pkg/status/templates $out/share/datadog-agent
|
2018-05-05 11:44:36 +00:00
|
|
|
|
2020-04-28 01:50:57 +00:00
|
|
|
wrapProgram "$out/bin/agent" \
|
|
|
|
--set PYTHONPATH "$out/${python.sitePackages}" \
|
2020-08-12 18:20:51 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : ${lib.getLib systemd}/lib
|
2018-05-05 11:44:36 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2018-05-05 11:44:36 +00:00
|
|
|
description = ''
|
|
|
|
Event collector for the DataDog analysis service
|
|
|
|
-- v6 new golang implementation.
|
|
|
|
'';
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://www.datadoghq.com";
|
2018-05-05 11:44:36 +00:00
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ thoughtpolice domenkozar rvl ];
|
|
|
|
};
|
|
|
|
}
|