at 23.11-beta 155 lines 6.0 kB view raw
1{ lib, stdenv, fetchFromGitHub, fetchpatch, autoreconfHook, pkg-config, makeWrapper 2, CoreFoundation, IOKit, libossp_uuid 3, nixosTests 4, netdata-go-plugins 5, bash, curl, jemalloc, json_c, 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 ? false 12, withCloudUi ? false 13, withConnPubSub ? false, google-cloud-cpp, grpc 14, withConnPrometheus ? false, snappy 15, withSsl ? true, openssl 16, withSystemdJournal ? (!stdenv.isDarwin), systemd 17, withDebug ? false 18}: 19 20stdenv.mkDerivation rec { 21 # Don't forget to update go.d.plugin.nix as well 22 version = "1.43.2"; 23 pname = "netdata"; 24 25 src = fetchFromGitHub { 26 owner = "netdata"; 27 repo = "netdata"; 28 rev = "v${version}"; 29 hash = if withCloudUi 30 then "sha256-ZhSuU2VTJPFJ3ja5eHx5uTuR19LleoID8Efr9FTyg74=" 31 else "sha256-t2awo118mYbuoNiKiAxM5xpRmQSha+/NR5G+shsotek="; 32 fetchSubmodules = true; 33 34 # Remove v2 dashboard distributed under NCUL1. Make sure an empty 35 # Makefile.am exists, as autoreconf will get confused otherwise. 36 postFetch = lib.optionalString (!withCloudUi) '' 37 rm -rf $out/web/gui/v2/* 38 touch $out/web/gui/v2/Makefile.am 39 ''; 40 }; 41 42 strictDeps = true; 43 44 nativeBuildInputs = [ autoreconfHook pkg-config makeWrapper protobuf ]; 45 # bash is only used to rewrite shebangs 46 buildInputs = [ bash curl jemalloc json_c libuv zlib libyaml ] 47 ++ lib.optionals stdenv.isDarwin [ CoreFoundation IOKit libossp_uuid ] 48 ++ lib.optionals (!stdenv.isDarwin) [ libcap libuuid ] 49 ++ lib.optionals withCups [ cups ] 50 ++ lib.optionals withDBengine [ lz4 ] 51 ++ lib.optionals withIpmi [ freeipmi ] 52 ++ lib.optionals withNetfilter [ libmnl libnetfilter_acct ] 53 ++ lib.optionals withConnPubSub [ google-cloud-cpp grpc ] 54 ++ lib.optionals withConnPrometheus [ snappy ] 55 ++ lib.optionals (withCloud || withConnPrometheus) [ protobuf ] 56 ++ lib.optionals withSystemdJournal [ systemd ] 57 ++ lib.optionals withSsl [ openssl ]; 58 59 patches = [ 60 # required to prevent plugins from relying on /etc 61 # and /var 62 ./no-files-in-etc-and-var.patch 63 64 # Avoid build-only inputs in closure leaked by configure command: 65 # https://github.com/NixOS/nixpkgs/issues/175693#issuecomment-1143344162 66 ./skip-CONFIGURE_COMMAND.patch 67 68 # Allow building without non-free v2 dashboard. 69 (fetchpatch { 70 url = "https://github.com/peat-psuwit/netdata/commit/6ccbdd1500db2b205923968688d5f1777430a326.patch"; 71 hash = "sha256-jAyk5HlxdjFn5IP6jOKP8/SXOraMQSA6r1krThe+s7g="; 72 }) 73 ]; 74 75 # Guard against unused buld-time development inputs in closure. Without 76 # the ./skip-CONFIGURE_COMMAND.patch patch the closure retains inputs up 77 # to bootstrap tools: 78 # https://github.com/NixOS/nixpkgs/pull/175719 79 # We pick zlib.dev as a simple canary package with pkg-config input. 80 disallowedReferences = lib.optional (!withDebug) zlib.dev; 81 82 donStrip = withDebug; 83 env.NIX_CFLAGS_COMPILE = lib.optionalString withDebug "-O1 -ggdb -DNETDATA_INTERNAL_CHECKS=1"; 84 85 postInstall = '' 86 ln -s ${netdata-go-plugins}/lib/netdata/conf.d/* $out/lib/netdata/conf.d 87 ln -s ${netdata-go-plugins}/bin/godplugin $out/libexec/netdata/plugins.d/go.d.plugin 88 '' + lib.optionalString (!stdenv.isDarwin) '' 89 # rename this plugin so netdata will look for setuid wrapper 90 mv $out/libexec/netdata/plugins.d/apps.plugin \ 91 $out/libexec/netdata/plugins.d/apps.plugin.org 92 mv $out/libexec/netdata/plugins.d/cgroup-network \ 93 $out/libexec/netdata/plugins.d/cgroup-network.org 94 mv $out/libexec/netdata/plugins.d/perf.plugin \ 95 $out/libexec/netdata/plugins.d/perf.plugin.org 96 mv $out/libexec/netdata/plugins.d/slabinfo.plugin \ 97 $out/libexec/netdata/plugins.d/slabinfo.plugin.org 98 ${lib.optionalString withSystemdJournal '' 99 mv $out/libexec/netdata/plugins.d/systemd-journal.plugin \ 100 $out/libexec/netdata/plugins.d/systemd-journal.plugin.org 101 ''} 102 ${lib.optionalString withIpmi '' 103 mv $out/libexec/netdata/plugins.d/freeipmi.plugin \ 104 $out/libexec/netdata/plugins.d/freeipmi.plugin.org 105 ''} 106 ''; 107 108 preConfigure = lib.optionalString (!stdenv.isDarwin) '' 109 substituteInPlace collectors/python.d.plugin/python_modules/third_party/lm_sensors.py \ 110 --replace 'ctypes.util.find_library("sensors")' '"${lm_sensors.out}/lib/libsensors${stdenv.hostPlatform.extensions.sharedLibrary}"' 111 ''; 112 113 configureFlags = [ 114 "--localstatedir=/var" 115 "--sysconfdir=/etc" 116 "--disable-ebpf" 117 "--with-jemalloc=${jemalloc}" 118 ] ++ lib.optionals (withSystemdJournal) [ 119 "--enable-plugin-systemd-journal" 120 ] ++ lib.optionals (!withDBengine) [ 121 "--disable-dbengine" 122 ] ++ lib.optionals (!withCloud) [ 123 "--disable-cloud" 124 ] ++ lib.optionals (!withCloudUi) [ 125 "--disable-cloud-ui" 126 ]; 127 128 postFixup = '' 129 # remove once https://github.com/netdata/netdata/pull/16300 merged 130 substituteInPlace $out/bin/netdata-claim.sh \ 131 --replace /bin/echo echo 132 133 wrapProgram $out/bin/netdata-claim.sh --prefix PATH : ${lib.makeBinPath [ openssl ]} 134 wrapProgram $out/libexec/netdata/plugins.d/cgroup-network-helper.sh --prefix PATH : ${lib.makeBinPath [ bash ]} 135 wrapProgram $out/bin/netdatacli --set NETDATA_PIPENAME /run/netdata/ipc 136 ''; 137 138 enableParallelBuild = true; 139 140 passthru = { 141 inherit withIpmi; 142 tests.netdata = nixosTests.netdata; 143 }; 144 145 meta = with lib; { 146 broken = stdenv.isDarwin || stdenv.buildPlatform != stdenv.hostPlatform; 147 description = "Real-time performance monitoring tool"; 148 homepage = "https://www.netdata.cloud/"; 149 changelog = "https://github.com/netdata/netdata/releases/tag/v${version}"; 150 license = [ licenses.gpl3Plus ] 151 ++ lib.optionals (withCloudUi) [ licenses.ncul1 ]; 152 platforms = platforms.unix; 153 maintainers = with maintainers; [ raitobezarius ]; 154 }; 155}