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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

126 lines
3.6 KiB
Nix
Raw Normal View History

{ lib
, stdenv
2022-08-08 14:09:47 +00:00
, cmake
2023-08-21 08:33:21 +00:00
, buildGoModule
, makeWrapper
, fetchFromGitHub
, pythonPackages
, pkg-config
, systemd
, hostname
, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, extraTags ? [ ]
2023-10-24 15:03:29 +00:00
, testers
, datadog-agent
}:
let
# keep this in sync with github.com/DataDog/agent-payload dependency
2023-10-24 15:03:29 +00:00
payloadVersion = "5.0.97";
python = pythonPackages.python;
owner = "DataDog";
repo = "datadog-agent";
goPackagePath = "github.com/${owner}/${repo}";
2023-11-17 09:04:23 +00:00
version = "7.49.0";
src = fetchFromGitHub {
inherit owner repo;
rev = version;
2023-11-17 09:04:23 +00:00
hash = "sha256-0/9Yngfnbq73ZWsHHF3yDNGBB+u4X9SKbv+lJdv0J/w=";
};
2022-08-08 14:09:47 +00:00
rtloader = stdenv.mkDerivation {
pname = "datadog-agent-rtloader";
src = "${src}/rtloader";
inherit version;
nativeBuildInputs = [ cmake ];
buildInputs = [ python ];
cmakeFlags = ["-DBUILD_DEMO=OFF" "-DDISABLE_PYTHON2=ON"];
};
2023-08-21 08:33:21 +00:00
in buildGoModule rec {
2022-08-08 14:09:47 +00:00
pname = "datadog-agent";
inherit src version;
doCheck = false;
2023-11-17 09:04:23 +00:00
vendorHash = "sha256-oBqH5sbT1+dLnAfouh4Vyds3M5pw5Z7u8XGGBTXflS0=";
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"
];
nativeBuildInputs = [ pkg-config makeWrapper ];
2022-08-08 14:09:47 +00:00
buildInputs = [rtloader] ++ lib.optionals withSystemd [ systemd ];
PKG_CONFIG_PATH = "${python}/lib/pkgconfig";
tags = [
"ec2"
2022-08-08 14:09:47 +00:00
"python"
"process"
"log"
"secrets"
2023-11-18 18:14:21 +00:00
"zlib"
]
++ 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 14:09:47 +00:00
"-X ${goPackagePath}/pkg/collector/python.pythonHome3=${python}"
"-X ${goPackagePath}/pkg/config.DefaultPython=3"
"-r ${python}/lib"
];
preBuild = ''
# 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
'';
# 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\"|" \
2023-10-24 15:03:29 +00:00
-i cmd/agent/common/path/path_nix.go
sed -e "s|/bin/hostname|${lib.getBin hostname}/bin/hostname|" \
2023-10-24 15:03:29 +00:00
-i pkg/util/hostname/fqdn_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 --no-preserve=mode $src/cmd/agent/dist/conf.d $out/share/datadog-agent
rm -rf $out/share/datadog-agent/conf.d/{apm.yaml.default,process_agent.yaml.default,winproc.d}
cp -R $src/cmd/agent/dist/{checks,utils,config.py} $out/${python.sitePackages}
cp -R $src/pkg/status/templates $out/share/datadog-agent
wrapProgram "$out/bin/agent" \
--set PYTHONPATH "$out/${python.sitePackages}"'' + lib.optionalString withSystemd '' \
--prefix LD_LIBRARY_PATH : '' + lib.makeLibraryPath [ (lib.getLib systemd) rtloader ];
2023-10-24 15:03:29 +00:00
passthru.tests.version = testers.testVersion {
package = datadog-agent;
command = "agent version";
};
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 viraptor ];
# never built on aarch64-darwin since first introduction in nixpkgs
broken = stdenv.isDarwin && stdenv.isAarch64;
};
}