at 22.05-pre 102 lines 3.5 kB view raw
1{ lib, stdenv, callPackage, fetchFromGitHub, autoreconfHook, pkg-config, makeWrapper 2, CoreFoundation, IOKit, libossp_uuid 3, nixosTests 4, curl, libcap, libuuid, lm_sensors, zlib 5, withCups ? false, cups 6, withDBengine ? true, libuv, lz4, judy 7, withIpmi ? (!stdenv.isDarwin), freeipmi 8, withNetfilter ? (!stdenv.isDarwin), libmnl, libnetfilter_acct 9, withCloud ? (!stdenv.isDarwin), json_c 10, withSsl ? true, openssl 11, withDebug ? false 12}: 13 14with lib; 15 16let 17 go-d-plugin = callPackage ./go.d.plugin.nix {}; 18in stdenv.mkDerivation rec { 19 version = "1.31.0"; 20 pname = "netdata"; 21 22 src = fetchFromGitHub { 23 owner = "netdata"; 24 repo = "netdata"; 25 rev = "v${version}"; 26 sha256 = "0735cxmljrp8zlkcq7hcxizy4j4xiv7vf782zkz5chn06n38mcik"; 27 fetchSubmodules = true; 28 }; 29 30 nativeBuildInputs = [ autoreconfHook pkg-config makeWrapper ]; 31 buildInputs = [ curl.dev zlib.dev ] 32 ++ optionals stdenv.isDarwin [ CoreFoundation IOKit libossp_uuid ] 33 ++ optionals (!stdenv.isDarwin) [ libcap.dev libuuid.dev ] 34 ++ optionals withCups [ cups ] 35 ++ optionals withDBengine [ libuv lz4.dev judy ] 36 ++ optionals withIpmi [ freeipmi ] 37 ++ optionals withNetfilter [ libmnl libnetfilter_acct ] 38 ++ optionals withCloud [ json_c ] 39 ++ optionals withSsl [ openssl.dev ]; 40 41 patches = [ 42 # required to prevent plugins from relying on /etc 43 # and /var 44 ./no-files-in-etc-and-var.patch 45 # The current IPC location is unsafe as it writes 46 # a fixed path in /tmp, which is world-writable. 47 # Therefore we put it into `/run/netdata`, which is owned 48 # by netdata only. 49 ./ipc-socket-in-run.patch 50 ]; 51 52 NIX_CFLAGS_COMPILE = optionalString withDebug "-O1 -ggdb -DNETDATA_INTERNAL_CHECKS=1"; 53 54 postInstall = '' 55 ln -s ${go-d-plugin}/lib/netdata/conf.d/* $out/lib/netdata/conf.d 56 ln -s ${go-d-plugin}/bin/godplugin $out/libexec/netdata/plugins.d/go.d.plugin 57 '' + optionalString (!stdenv.isDarwin) '' 58 # rename this plugin so netdata will look for setuid wrapper 59 mv $out/libexec/netdata/plugins.d/apps.plugin \ 60 $out/libexec/netdata/plugins.d/apps.plugin.org 61 mv $out/libexec/netdata/plugins.d/cgroup-network \ 62 $out/libexec/netdata/plugins.d/cgroup-network.org 63 mv $out/libexec/netdata/plugins.d/perf.plugin \ 64 $out/libexec/netdata/plugins.d/perf.plugin.org 65 mv $out/libexec/netdata/plugins.d/slabinfo.plugin \ 66 $out/libexec/netdata/plugins.d/slabinfo.plugin.org 67 ${optionalString withIpmi '' 68 mv $out/libexec/netdata/plugins.d/freeipmi.plugin \ 69 $out/libexec/netdata/plugins.d/freeipmi.plugin.org 70 ''} 71 ''; 72 73 preConfigure = optionalString (!stdenv.isDarwin) '' 74 substituteInPlace collectors/python.d.plugin/python_modules/third_party/lm_sensors.py \ 75 --replace 'ctypes.util.find_library("sensors")' '"${lm_sensors.out}/lib/libsensors${stdenv.hostPlatform.extensions.sharedLibrary}"' 76 ''; 77 78 configureFlags = [ 79 "--localstatedir=/var" 80 "--sysconfdir=/etc" 81 ] ++ optionals withCloud [ 82 "--enable-cloud" 83 "--with-aclk-ng" 84 ]; 85 86 postFixup = '' 87 wrapProgram $out/bin/netdata-claim.sh --prefix PATH : ${lib.makeBinPath [ openssl ]} 88 ''; 89 90 passthru = { 91 inherit withIpmi; 92 tests.netdata = nixosTests.netdata; 93 }; 94 95 meta = { 96 description = "Real-time performance monitoring tool"; 97 homepage = "https://www.netdata.cloud/"; 98 license = licenses.gpl3Plus; 99 platforms = platforms.unix; 100 maintainers = [ ]; 101 }; 102}