nixpkgs/pkgs/tools/networking/dd-agent/datadog-agent.nix

81 lines
2.6 KiB
Nix
Raw Normal View History

{ lib, fetchFromGitHub, buildGoPackage, makeWrapper, pythonPackages, pkg-config, systemd, hostname, extraTags ? [] }:
let
# keep this in sync with github.com/DataDog/agent-payload dependency
2018-09-08 22:39:55 +01:00
payloadVersion = "4.7.1";
python = pythonPackages.python;
in buildGoPackage rec {
pname = "datadog-agent";
2019-05-21 18:53:06 +01:00
version = "6.11.2";
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";
};
subPackages = [
"cmd/agent"
2019-03-01 07:21:10 +00:00
"cmd/cluster-agent"
"cmd/dogstatsd"
"cmd/py-launcher"
2019-03-01 07:21:10 +00:00
"cmd/trace-agent"
];
2019-04-19 08:09:54 +01:00
goDeps = ./datadog-agent-deps.nix;
goPackagePath = "github.com/${owner}/${repo}";
2021-01-17 03:51:22 +00:00
nativeBuildInputs = [ pkg-config makeWrapper ];
2018-09-08 22:39:55 +01:00
buildInputs = [ systemd ];
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 " " [
"-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 ''
buildFlagsArray=( "-tags" "ec2 systemd cpython process log secrets ${lib.concatStringsSep " " extraTags}" "-ldflags" "${ldFlags}")
2018-09-08 22:39:55 +01:00
'';
# 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/common_nix.go
sed -e "s|/bin/hostname|${lib.getBin hostname}/bin/hostname|" \
-i pkg/util/hostname_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 $src/cmd/agent/dist/conf.d $out/share/datadog-agent
cp -R $src/cmd/agent/dist/{checks,utils,config.py} $out/${python.sitePackages}
cp -R $src/pkg/status/dist/templates $out/share/datadog-agent
wrapProgram "$out/bin/agent" \
--set PYTHONPATH "$out/${python.sitePackages}" \
--prefix LD_LIBRARY_PATH : ${lib.getLib systemd}/lib
'';
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 ];
};
}