datadog-agent: make systemd optional
Allow compiling without systemd support and disable that by default on non-Linux platforms. This allows compiling the agent on Darwin.
This commit is contained in:
parent
1d6c1ed507
commit
95a7f0244a
1 changed files with 34 additions and 14 deletions
|
@ -1,4 +1,15 @@
|
|||
{ lib, buildGoModule, makeWrapper, fetchFromGitHub, pythonPackages, pkg-config, systemd, hostname, extraTags ? [] }:
|
||||
{ lib
|
||||
, stdenv
|
||||
, buildGoModule
|
||||
, makeWrapper
|
||||
, fetchFromGitHub
|
||||
, pythonPackages
|
||||
, pkg-config
|
||||
, systemd
|
||||
, hostname
|
||||
, withSystemd ? stdenv.isLinux
|
||||
, extraTags ? [ ]
|
||||
}:
|
||||
|
||||
let
|
||||
# keep this in sync with github.com/DataDog/agent-payload dependency
|
||||
|
@ -30,19 +41,28 @@ in buildGoModule rec {
|
|||
|
||||
|
||||
nativeBuildInputs = [ pkg-config makeWrapper ];
|
||||
buildInputs = [ systemd ];
|
||||
buildInputs = lib.optionals withSystemd [ systemd ];
|
||||
PKG_CONFIG_PATH = "${python}/lib/pkgconfig";
|
||||
|
||||
preBuild = let
|
||||
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"
|
||||
];
|
||||
in ''
|
||||
buildFlagsArray=( "-tags" "ec2 systemd cpython process log secrets ${lib.concatStringsSep " " extraTags}" "-ldflags" "${ldFlags}")
|
||||
tags = [
|
||||
"ec2"
|
||||
"cpython"
|
||||
"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}"
|
||||
"-X ${goPackagePath}/pkg/collector/py.pythonHome=${python}"
|
||||
"-r ${python}/lib"
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
# Keep directories to generate in sync with tasks/go.py
|
||||
go generate ./pkg/status ./cmd/agent/gui
|
||||
'';
|
||||
|
@ -66,7 +86,7 @@ in buildGoModule rec {
|
|||
cp -R $src/pkg/status/templates $out/share/datadog-agent
|
||||
|
||||
wrapProgram "$out/bin/agent" \
|
||||
--set PYTHONPATH "$out/${python.sitePackages}" \
|
||||
--set PYTHONPATH "$out/${python.sitePackages}"'' + lib.optionalString withSystemd '' \
|
||||
--prefix LD_LIBRARY_PATH : ${lib.getLib systemd}/lib
|
||||
'';
|
||||
|
||||
|
@ -77,6 +97,6 @@ in buildGoModule rec {
|
|||
'';
|
||||
homepage = "https://www.datadoghq.com";
|
||||
license = licenses.bsd3;
|
||||
maintainers = with maintainers; [ thoughtpolice domenkozar rvl ];
|
||||
maintainers = with maintainers; [ thoughtpolice domenkozar rvl viraptor ];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue