2022-04-28 02:01:27 +01:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2022-08-08 15:09:47 +01:00
|
|
|
, cmake
|
2022-12-07 12:20:28 +00:00
|
|
|
, buildGo118Module
|
2022-04-28 02:01:27 +01:00
|
|
|
, makeWrapper
|
|
|
|
, fetchFromGitHub
|
|
|
|
, pythonPackages
|
|
|
|
, pkg-config
|
|
|
|
, systemd
|
|
|
|
, hostname
|
2022-09-21 08:04:52 +01:00
|
|
|
, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
|
2022-04-28 02:01:27 +01:00
|
|
|
, extraTags ? [ ]
|
|
|
|
}:
|
2018-05-05 12:44:36 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
# keep this in sync with github.com/DataDog/agent-payload dependency
|
2021-08-29 03:37:58 +01:00
|
|
|
payloadVersion = "4.78.0";
|
2019-06-27 18:52:16 +01:00
|
|
|
python = pythonPackages.python;
|
2018-05-05 12:44:36 +01:00
|
|
|
owner = "DataDog";
|
|
|
|
repo = "datadog-agent";
|
2021-08-29 03:37:58 +01:00
|
|
|
goPackagePath = "github.com/${owner}/${repo}";
|
2022-08-09 16:48:21 +01:00
|
|
|
version = "7.38.1";
|
2018-05-05 12:44:36 +01:00
|
|
|
|
2021-09-08 00:19:17 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
inherit owner repo;
|
2021-08-29 03:37:58 +01:00
|
|
|
rev = version;
|
2022-08-09 16:48:21 +01:00
|
|
|
sha256 = "sha256-bG8wsSQvZcG4/Th6mWVdVX9vpeYBZx8FxwdYXpIdXnU=";
|
2018-05-05 12:44:36 +01:00
|
|
|
};
|
2022-08-08 15:09:47 +01:00
|
|
|
rtloader = stdenv.mkDerivation {
|
|
|
|
pname = "datadog-agent-rtloader";
|
|
|
|
src = "${src}/rtloader";
|
|
|
|
inherit version;
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
buildInputs = [ python ];
|
|
|
|
cmakeFlags = ["-DBUILD_DEMO=OFF" "-DDISABLE_PYTHON2=ON"];
|
|
|
|
};
|
|
|
|
|
2022-12-07 12:20:28 +00:00
|
|
|
in buildGo118Module rec {
|
2022-08-08 15:09:47 +01:00
|
|
|
pname = "datadog-agent";
|
|
|
|
inherit src version;
|
|
|
|
|
|
|
|
doCheck = false;
|
2018-05-05 12:44:36 +01:00
|
|
|
|
2022-08-09 16:48:21 +01:00
|
|
|
vendorSha256 = "sha256-bGDf48wFa32hURZfGN5pCMmslC3PeLNayKcl5cfjq9M=";
|
2021-08-29 03:37:58 +01:00
|
|
|
|
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
|
|
|
];
|
|
|
|
|
2018-08-09 14:33:22 +01:00
|
|
|
|
2021-09-08 00:19:17 +01:00
|
|
|
nativeBuildInputs = [ pkg-config makeWrapper ];
|
2022-08-08 15:09:47 +01:00
|
|
|
buildInputs = [rtloader] ++ lib.optionals withSystemd [ systemd ];
|
2018-05-05 12:44:36 +01:00
|
|
|
PKG_CONFIG_PATH = "${python}/lib/pkgconfig";
|
|
|
|
|
2022-04-28 02:01:27 +01:00
|
|
|
tags = [
|
|
|
|
"ec2"
|
2022-08-08 15:09:47 +01:00
|
|
|
"python"
|
2022-04-28 02:01:27 +01:00
|
|
|
"process"
|
|
|
|
"log"
|
|
|
|
"secrets"
|
|
|
|
]
|
|
|
|
++ 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}"
|
2022-08-08 15:09:47 +01:00
|
|
|
"-X ${goPackagePath}/pkg/collector/python.pythonHome3=${python}"
|
|
|
|
"-X ${goPackagePath}/pkg/config.DefaultPython=3"
|
2022-04-28 02:01:27 +01:00
|
|
|
"-r ${python}/lib"
|
|
|
|
];
|
|
|
|
|
|
|
|
preBuild = ''
|
2021-09-08 00:19:17 +01:00
|
|
|
# Keep directories to generate in sync with tasks/go.py
|
|
|
|
go generate ./pkg/status ./cmd/agent/gui
|
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
|
|
|
|
2021-08-29 03:37:58 +01:00
|
|
|
cp -R $src/pkg/status/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" \
|
2022-04-28 02:01:27 +01:00
|
|
|
--set PYTHONPATH "$out/${python.sitePackages}"'' + lib.optionalString withSystemd '' \
|
2022-12-07 12:06:54 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : '' + lib.makeLibraryPath [ (lib.getLib systemd) rtloader ];
|
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;
|
2022-04-28 02:01:27 +01:00
|
|
|
maintainers = with maintainers; [ thoughtpolice domenkozar rvl viraptor ];
|
2022-12-06 20:47:40 +00:00
|
|
|
# never built on aarch64-darwin since first introduction in nixpkgs
|
|
|
|
broken = stdenv.isDarwin && stdenv.isAarch64;
|
2018-05-05 12:44:36 +01:00
|
|
|
};
|
|
|
|
}
|