Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchFromGitHub, autoreconfHook, pkg-config, makeWrapper 2, CoreFoundation, IOKit, libossp_uuid 3, nixosTests 4, netdata-go-plugins 5, bash, curl, jemalloc, libuv, zlib, libyaml 6, libcap, libuuid, lm_sensors, protobuf 7, withCups ? false, cups 8, withDBengine ? true, lz4 9, withIpmi ? (!stdenv.isDarwin), freeipmi 10, withNetfilter ? (!stdenv.isDarwin), libmnl, libnetfilter_acct 11, withCloud ? (!stdenv.isDarwin), json_c 12, withConnPubSub ? false, google-cloud-cpp, grpc 13, withConnPrometheus ? false, snappy 14, withSsl ? true, openssl 15, withDebug ? false 16}: 17 18stdenv.mkDerivation rec { 19 # Don't forget to update go.d.plugin.nix as well 20 version = "1.39.1"; 21 pname = "netdata"; 22 23 src = fetchFromGitHub { 24 owner = "netdata"; 25 repo = "netdata"; 26 rev = "v${version}"; 27 sha256 = "sha256-jioQAUBc9jKmLgu9117TCqI/v+VMSD0CIMzEzG8J0OA="; 28 fetchSubmodules = true; 29 }; 30 31 strictDeps = true; 32 33 nativeBuildInputs = [ autoreconfHook pkg-config makeWrapper protobuf ]; 34 # bash is only used to rewrite shebangs 35 buildInputs = [ bash curl jemalloc libuv zlib libyaml ] 36 ++ lib.optionals stdenv.isDarwin [ CoreFoundation IOKit libossp_uuid ] 37 ++ lib.optionals (!stdenv.isDarwin) [ libcap libuuid ] 38 ++ lib.optionals withCups [ cups ] 39 ++ lib.optionals withDBengine [ lz4 ] 40 ++ lib.optionals withIpmi [ freeipmi ] 41 ++ lib.optionals withNetfilter [ libmnl libnetfilter_acct ] 42 ++ lib.optionals withCloud [ json_c ] 43 ++ lib.optionals withConnPubSub [ google-cloud-cpp grpc ] 44 ++ lib.optionals withConnPrometheus [ snappy ] 45 ++ lib.optionals (withCloud || withConnPrometheus) [ protobuf ] 46 ++ lib.optionals withSsl [ openssl ]; 47 48 patches = [ 49 # required to prevent plugins from relying on /etc 50 # and /var 51 ./no-files-in-etc-and-var.patch 52 # The current IPC location is unsafe as it writes 53 # a fixed path in /tmp, which is world-writable. 54 # Therefore we put it into `/run/netdata`, which is owned 55 # by netdata only. 56 ./ipc-socket-in-run.patch 57 58 # Avoid build-only inputs in closure leaked by configure command: 59 # https://github.com/NixOS/nixpkgs/issues/175693#issuecomment-1143344162 60 ./skip-CONFIGURE_COMMAND.patch 61 ]; 62 63 # Guard against unused buld-time development inputs in closure. Without 64 # the ./skip-CONFIGURE_COMMAND.patch patch the closure retains inputs up 65 # to bootstrap tools: 66 # https://github.com/NixOS/nixpkgs/pull/175719 67 # We pick zlib.dev as a simple canary package with pkg-config input. 68 disallowedReferences = if withDebug then [] else [ zlib.dev ]; 69 70 donStrip = withDebug; 71 env.NIX_CFLAGS_COMPILE = lib.optionalString withDebug "-O1 -ggdb -DNETDATA_INTERNAL_CHECKS=1"; 72 73 postInstall = '' 74 ln -s ${netdata-go-plugins}/lib/netdata/conf.d/* $out/lib/netdata/conf.d 75 ln -s ${netdata-go-plugins}/bin/godplugin $out/libexec/netdata/plugins.d/go.d.plugin 76 '' + lib.optionalString (!stdenv.isDarwin) '' 77 # rename this plugin so netdata will look for setuid wrapper 78 mv $out/libexec/netdata/plugins.d/apps.plugin \ 79 $out/libexec/netdata/plugins.d/apps.plugin.org 80 mv $out/libexec/netdata/plugins.d/cgroup-network \ 81 $out/libexec/netdata/plugins.d/cgroup-network.org 82 mv $out/libexec/netdata/plugins.d/perf.plugin \ 83 $out/libexec/netdata/plugins.d/perf.plugin.org 84 mv $out/libexec/netdata/plugins.d/slabinfo.plugin \ 85 $out/libexec/netdata/plugins.d/slabinfo.plugin.org 86 ${lib.optionalString withIpmi '' 87 mv $out/libexec/netdata/plugins.d/freeipmi.plugin \ 88 $out/libexec/netdata/plugins.d/freeipmi.plugin.org 89 ''} 90 ''; 91 92 preConfigure = lib.optionalString (!stdenv.isDarwin) '' 93 substituteInPlace collectors/python.d.plugin/python_modules/third_party/lm_sensors.py \ 94 --replace 'ctypes.util.find_library("sensors")' '"${lm_sensors.out}/lib/libsensors${stdenv.hostPlatform.extensions.sharedLibrary}"' 95 ''; 96 97 configureFlags = [ 98 "--localstatedir=/var" 99 "--sysconfdir=/etc" 100 "--disable-ebpf" 101 "--with-jemalloc=${jemalloc}" 102 ] ++ lib.optionals (!withDBengine) [ 103 "--disable-dbengine" 104 ] ++ lib.optionals (!withCloud) [ 105 "--disable-cloud" 106 ]; 107 108 postFixup = '' 109 wrapProgram $out/bin/netdata-claim.sh --prefix PATH : ${lib.makeBinPath [ openssl ]} 110 wrapProgram $out/libexec/netdata/plugins.d/cgroup-network-helper.sh --prefix PATH : ${lib.makeBinPath [ bash ]} 111 ''; 112 113 enableParallelBuild = true; 114 115 passthru = { 116 inherit withIpmi; 117 tests.netdata = nixosTests.netdata; 118 }; 119 120 meta = with lib; { 121 broken = stdenv.isDarwin || stdenv.buildPlatform != stdenv.hostPlatform; 122 description = "Real-time performance monitoring tool"; 123 homepage = "https://www.netdata.cloud/"; 124 changelog = "https://github.com/netdata/netdata/releases/tag/v${version}"; 125 license = licenses.gpl3Plus; 126 platforms = platforms.unix; 127 maintainers = with maintainers; [ raitobezarius ]; 128 }; 129}