Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 138 lines 3.9 kB view raw
1{ 2 lib, 3 stdenv, 4 cmake, 5 buildGoModule, 6 makeWrapper, 7 fetchFromGitHub, 8 pythonPackages, 9 pkg-config, 10 systemd, 11 hostname, 12 withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd, 13 withDocker ? true, 14 extraTags ? [ ], 15 testers, 16 datadog-agent, 17}: 18 19let 20 # keep this in sync with github.com/DataDog/agent-payload dependency 21 payloadVersion = "5.0.124"; 22 python = pythonPackages.python; 23 owner = "DataDog"; 24 repo = "datadog-agent"; 25 goPackagePath = "github.com/${owner}/${repo}"; 26 version = "7.56.2"; 27 28 src = fetchFromGitHub { 29 inherit owner repo; 30 rev = version; 31 hash = "sha256-rU3eg92MuGs/6r7oJho2roeUCZoyfqYt1xOERoRPqmQ="; 32 }; 33 rtloader = stdenv.mkDerivation { 34 pname = "datadog-agent-rtloader"; 35 src = "${src}/rtloader"; 36 inherit version; 37 nativeBuildInputs = [ cmake ]; 38 buildInputs = [ python ]; 39 cmakeFlags = [ 40 "-DBUILD_DEMO=OFF" 41 "-DDISABLE_PYTHON2=ON" 42 ]; 43 }; 44 45in 46buildGoModule rec { 47 pname = "datadog-agent"; 48 inherit src version; 49 50 doCheck = false; 51 52 vendorHash = 53 if stdenv.hostPlatform.isDarwin then 54 "sha256-3Piq5DPMTZUEjqNkw5HZY25An2kATX6Jac9unQfZnZc=" 55 else 56 "sha256-FR0Et3DvjJhbYUPy9mpN0QCJ7QDU4VRZFUTL0J1FSXw="; 57 58 subPackages = [ 59 "cmd/agent" 60 "cmd/cluster-agent" 61 "cmd/dogstatsd" 62 "cmd/trace-agent" 63 ]; 64 65 nativeBuildInputs = [ 66 pkg-config 67 makeWrapper 68 ]; 69 buildInputs = [ rtloader ] ++ lib.optionals withSystemd [ systemd ]; 70 PKG_CONFIG_PATH = "${python}/lib/pkgconfig"; 71 72 tags = [ 73 "ec2" 74 "python" 75 "process" 76 "log" 77 "secrets" 78 "zlib" 79 ] 80 ++ lib.optionals withSystemd [ "systemd" ] 81 ++ lib.optionals withDocker [ "docker" ] 82 ++ extraTags; 83 84 ldflags = [ 85 "-X ${goPackagePath}/pkg/version.Commit=${src.rev}" 86 "-X ${goPackagePath}/pkg/version.AgentVersion=${version}" 87 "-X ${goPackagePath}/pkg/serializer.AgentPayloadVersion=${payloadVersion}" 88 "-X ${goPackagePath}/pkg/collector/python.pythonHome3=${python}" 89 "-X ${goPackagePath}/pkg/config/setup.DefaultPython=3" 90 "-r ${python}/lib" 91 ]; 92 93 # DataDog use paths relative to the agent binary, so fix these. 94 # We can't just point these to $out since that would introduce self-referential paths in the go modules, 95 # which are a fixed-output derivation. However, the patches aren't picked up if we skip them when building 96 # the modules. So we'll just traverse from the bin back to the out folder. 97 postPatch = '' 98 sed -e "s|PyChecksPath =.*|PyChecksPath = filepath.Join(_here, \"..\", \"${python.sitePackages}\")|" \ 99 -e "s|distPath =.*|distPath = filepath.Join(_here, \"..\", \"share\", \"datadog-agent\")|" \ 100 -i cmd/agent/common/path/path_nix.go 101 sed -e "s|/bin/hostname|${lib.getBin hostname}/bin/hostname|" \ 102 -i pkg/util/hostname/fqdn_nix.go 103 ''; 104 105 # Install the config files and python modules from the "dist" dir 106 # into standard paths. 107 postInstall = '' 108 mkdir -p $out/${python.sitePackages} $out/share/datadog-agent 109 cp -R --no-preserve=mode $src/cmd/agent/dist/conf.d $out/share/datadog-agent 110 rm -rf $out/share/datadog-agent/conf.d/{apm.yaml.default,process_agent.yaml.default,winproc.d,agentcrashdetect.d,myapp.d} 111 cp -R $src/cmd/agent/dist/{checks,utils,config.py} $out/${python.sitePackages} 112 113 wrapProgram "$out/bin/agent" \ 114 --set PYTHONPATH "$out/${python.sitePackages}"'' 115 + lib.optionalString withSystemd " --prefix LD_LIBRARY_PATH : ${ 116 lib.makeLibraryPath [ 117 (lib.getLib systemd) 118 rtloader 119 ] 120 }"; 121 122 passthru.tests.version = testers.testVersion { 123 package = datadog-agent; 124 command = "agent version"; 125 }; 126 127 meta = with lib; { 128 description = '' 129 Event collector for the DataDog analysis service 130 -- v6 new golang implementation. 131 ''; 132 homepage = "https://www.datadoghq.com"; 133 license = licenses.bsd3; 134 maintainers = with maintainers; [ 135 thoughtpolice 136 ]; 137 }; 138}