nixpkgs/pkgs/tools/system/netdata/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

126 lines
4.5 KiB
Nix
Raw Normal View History

{ lib, stdenv, callPackage, fetchFromGitHub, autoreconfHook, pkg-config, makeWrapper
2019-07-03 10:49:29 +00:00
, CoreFoundation, IOKit, libossp_uuid
2020-08-28 08:49:26 +00:00
, nixosTests
, netdata-go-d-plugin
, curl, jemalloc, libuv, zlib
, libcap, libuuid, lm_sensors, protobuf
2019-07-03 10:49:29 +00:00
, withCups ? false, cups
, withDBengine ? true, lz4
2019-07-03 10:49:29 +00:00
, withIpmi ? (!stdenv.isDarwin), freeipmi
, withNetfilter ? (!stdenv.isDarwin), libmnl, libnetfilter_acct
, withCloud ? (!stdenv.isDarwin), json_c
, withConnPubSub ? false, google-cloud-cpp, grpc
, withConnPrometheus ? false, snappy
2019-07-03 10:49:29 +00:00
, withSsl ? true, openssl
2019-07-04 10:08:11 +00:00
, withDebug ? false
2019-07-03 10:49:29 +00:00
}:
2016-04-14 21:43:01 +00:00
stdenv.mkDerivation rec {
2023-02-14 13:53:04 +00:00
# Don't forget to update go.d.plugin.nix as well
version = "1.38.1";
pname = "netdata";
2016-04-14 21:43:01 +00:00
2019-12-07 21:04:30 +00:00
src = fetchFromGitHub {
owner = "netdata";
repo = "netdata";
rev = "v${version}";
2023-02-14 13:53:04 +00:00
sha256 = "sha256-y+rjqS95JS1PU+iR8c7spcg1UoYCjpzbpunTAgTJ35U=";
2021-05-19 17:35:24 +00:00
fetchSubmodules = true;
2016-04-14 21:43:01 +00:00
};
strictDeps = true;
nativeBuildInputs = [ autoreconfHook pkg-config makeWrapper protobuf ];
buildInputs = [ curl jemalloc libuv zlib ]
++ lib.optionals stdenv.isDarwin [ CoreFoundation IOKit libossp_uuid ]
++ lib.optionals (!stdenv.isDarwin) [ libcap libuuid ]
++ lib.optionals withCups [ cups ]
++ lib.optionals withDBengine [ lz4 ]
++ lib.optionals withIpmi [ freeipmi ]
++ lib.optionals withNetfilter [ libmnl libnetfilter_acct ]
++ lib.optionals withCloud [ json_c ]
++ lib.optionals withConnPubSub [ google-cloud-cpp grpc ]
++ lib.optionals withConnPrometheus [ snappy ]
++ lib.optionals (withCloud || withConnPrometheus) [ protobuf ]
++ lib.optionals withSsl [ openssl ];
2016-04-14 21:43:01 +00:00
patches = [
# required to prevent plugins from relying on /etc
# and /var
./no-files-in-etc-and-var.patch
# The current IPC location is unsafe as it writes
# a fixed path in /tmp, which is world-writable.
# Therefore we put it into `/run/netdata`, which is owned
# by netdata only.
./ipc-socket-in-run.patch
# Avoid build-only inputs in closure leaked by configure command:
# https://github.com/NixOS/nixpkgs/issues/175693#issuecomment-1143344162
./skip-CONFIGURE_COMMAND.patch
];
# Guard against unused buld-time development inputs in closure. Without
# the ./skip-CONFIGURE_COMMAND.patch patch the closure retains inputs up
# to bootstrap tools:
# https://github.com/NixOS/nixpkgs/pull/175719
# We pick zlib.dev as a simple canary package with pkg-config input.
disallowedReferences = [ zlib.dev ];
env.NIX_CFLAGS_COMPILE = lib.optionalString withDebug "-O1 -ggdb -DNETDATA_INTERNAL_CHECKS=1";
2019-07-04 10:08:11 +00:00
2020-02-22 07:45:50 +00:00
postInstall = ''
ln -s ${netdata-go-d-plugin}/lib/netdata/conf.d/* $out/lib/netdata/conf.d
ln -s ${netdata-go-d-plugin}/bin/godplugin $out/libexec/netdata/plugins.d/go.d.plugin
'' + lib.optionalString (!stdenv.isDarwin) ''
# rename this plugin so netdata will look for setuid wrapper
mv $out/libexec/netdata/plugins.d/apps.plugin \
2019-06-26 17:38:01 +00:00
$out/libexec/netdata/plugins.d/apps.plugin.org
mv $out/libexec/netdata/plugins.d/cgroup-network \
$out/libexec/netdata/plugins.d/cgroup-network.org
mv $out/libexec/netdata/plugins.d/perf.plugin \
$out/libexec/netdata/plugins.d/perf.plugin.org
mv $out/libexec/netdata/plugins.d/slabinfo.plugin \
$out/libexec/netdata/plugins.d/slabinfo.plugin.org
${lib.optionalString withIpmi ''
mv $out/libexec/netdata/plugins.d/freeipmi.plugin \
$out/libexec/netdata/plugins.d/freeipmi.plugin.org
''}
'';
preConfigure = lib.optionalString (!stdenv.isDarwin) ''
2019-03-07 21:01:48 +00:00
substituteInPlace collectors/python.d.plugin/python_modules/third_party/lm_sensors.py \
--replace 'ctypes.util.find_library("sensors")' '"${lm_sensors.out}/lib/libsensors${stdenv.hostPlatform.extensions.sharedLibrary}"'
'';
configureFlags = [
"--localstatedir=/var"
"--sysconfdir=/etc"
"--disable-ebpf"
"--with-jemalloc=${jemalloc}"
] ++ lib.optionals (!withDBengine) [
"--disable-dbengine"
] ++ lib.optionals (!withCloud) [
"--disable-cloud"
];
2018-11-14 16:01:41 +00:00
postFixup = ''
wrapProgram $out/bin/netdata-claim.sh --prefix PATH : ${lib.makeBinPath [ openssl ]}
2016-10-14 10:05:42 +00:00
'';
2022-06-18 20:21:18 +00:00
enableParallelBuild = true;
passthru = {
inherit withIpmi;
tests.netdata = nixosTests.netdata;
};
2020-08-28 08:49:26 +00:00
meta = with lib; {
broken = stdenv.isDarwin || stdenv.buildPlatform != stdenv.hostPlatform;
2016-04-14 21:43:01 +00:00
description = "Real-time performance monitoring tool";
homepage = "https://www.netdata.cloud/";
license = licenses.gpl3Plus;
2018-11-14 16:01:41 +00:00
platforms = platforms.unix;
maintainers = [ ];
2016-04-14 21:43:01 +00:00
};
}