2023-10-09 19:29:22 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, autoreconfHook, pkg-config, makeWrapper
|
2020-04-24 23:36:52 +00:00
|
|
|
, CoreFoundation, IOKit, libossp_uuid
|
2020-09-25 04:45:31 +00:00
|
|
|
, nixosTests
|
2023-03-08 16:32:21 +00:00
|
|
|
, netdata-go-plugins
|
2023-11-16 04:20:00 +00:00
|
|
|
, bash, curl, jemalloc, json_c, libuv, zlib, libyaml
|
2022-07-14 12:49:19 +00:00
|
|
|
, libcap, libuuid, lm_sensors, protobuf
|
2020-04-24 23:36:52 +00:00
|
|
|
, withCups ? false, cups
|
2023-01-20 10:41:00 +00:00
|
|
|
, withDBengine ? true, lz4
|
2020-04-24 23:36:52 +00:00
|
|
|
, withIpmi ? (!stdenv.isDarwin), freeipmi
|
|
|
|
, withNetfilter ? (!stdenv.isDarwin), libmnl, libnetfilter_acct
|
2023-11-16 04:20:00 +00:00
|
|
|
, withCloud ? false
|
2023-10-09 19:29:22 +00:00
|
|
|
, withCloudUi ? false
|
2022-07-14 12:49:19 +00:00
|
|
|
, withConnPubSub ? false, google-cloud-cpp, grpc
|
|
|
|
, withConnPrometheus ? false, snappy
|
2020-04-24 23:36:52 +00:00
|
|
|
, withSsl ? true, openssl
|
2023-11-16 04:20:00 +00:00
|
|
|
, withSystemdJournal ? (!stdenv.isDarwin), systemd
|
2020-04-24 23:36:52 +00:00
|
|
|
, withDebug ? false
|
|
|
|
}:
|
|
|
|
|
2023-03-08 16:32:21 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2023-02-16 17:41:37 +00:00
|
|
|
# Don't forget to update go.d.plugin.nix as well
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "1.44.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "netdata";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "netdata";
|
|
|
|
repo = "netdata";
|
|
|
|
rev = "v${version}";
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = if withCloudUi
|
2024-01-02 11:29:13 +00:00
|
|
|
then "sha256-8kkOpMfcYPcHI3GuevZ2NYjJjlZvrvBgIs883Zsztgw="
|
|
|
|
else "sha256-Kui3sV8OzBri4h47qD10snQgdvdi6yi/2z4cXWREcxE=";
|
2021-05-29 03:34:57 +00:00
|
|
|
fetchSubmodules = true;
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
# Remove v2 dashboard distributed under NCUL1. Make sure an empty
|
|
|
|
# Makefile.am exists, as autoreconf will get confused otherwise.
|
|
|
|
postFetch = lib.optionalString (!withCloudUi) ''
|
|
|
|
rm -rf $out/web/gui/v2/*
|
|
|
|
touch $out/web/gui/v2/Makefile.am
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
nativeBuildInputs = [ autoreconfHook pkg-config makeWrapper protobuf ];
|
2023-03-08 16:32:21 +00:00
|
|
|
# bash is only used to rewrite shebangs
|
2023-11-16 04:20:00 +00:00
|
|
|
buildInputs = [ bash curl jemalloc json_c libuv zlib libyaml ]
|
2023-02-02 18:25:31 +00:00
|
|
|
++ 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 withConnPubSub [ google-cloud-cpp grpc ]
|
|
|
|
++ lib.optionals withConnPrometheus [ snappy ]
|
|
|
|
++ lib.optionals (withCloud || withConnPrometheus) [ protobuf ]
|
2023-11-16 04:20:00 +00:00
|
|
|
++ lib.optionals withSystemdJournal [ systemd ]
|
2023-02-02 18:25:31 +00:00
|
|
|
++ lib.optionals withSsl [ openssl ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
patches = [
|
2021-02-22 21:28:39 +00:00
|
|
|
# required to prevent plugins from relying on /etc
|
|
|
|
# and /var
|
2020-04-24 23:36:52 +00:00
|
|
|
./no-files-in-etc-and-var.patch
|
2022-06-16 17:23:12 +00:00
|
|
|
|
|
|
|
# Avoid build-only inputs in closure leaked by configure command:
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/175693#issuecomment-1143344162
|
|
|
|
./skip-CONFIGURE_COMMAND.patch
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
# Allow building without non-free v2 dashboard.
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/peat-psuwit/netdata/commit/6ccbdd1500db2b205923968688d5f1777430a326.patch";
|
|
|
|
hash = "sha256-jAyk5HlxdjFn5IP6jOKP8/SXOraMQSA6r1krThe+s7g=";
|
|
|
|
})
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
# 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.
|
2023-07-15 17:15:38 +00:00
|
|
|
disallowedReferences = lib.optional (!withDebug) zlib.dev;
|
2022-06-16 17:23:12 +00:00
|
|
|
|
2023-03-08 16:32:21 +00:00
|
|
|
donStrip = withDebug;
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = lib.optionalString withDebug "-O1 -ggdb -DNETDATA_INTERNAL_CHECKS=1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
2023-03-08 16:32:21 +00:00
|
|
|
ln -s ${netdata-go-plugins}/lib/netdata/conf.d/* $out/lib/netdata/conf.d
|
|
|
|
ln -s ${netdata-go-plugins}/bin/godplugin $out/libexec/netdata/plugins.d/go.d.plugin
|
2023-02-02 18:25:31 +00:00
|
|
|
'' + lib.optionalString (!stdenv.isDarwin) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
# rename this plugin so netdata will look for setuid wrapper
|
|
|
|
mv $out/libexec/netdata/plugins.d/apps.plugin \
|
|
|
|
$out/libexec/netdata/plugins.d/apps.plugin.org
|
2021-05-20 23:08:51 +00:00
|
|
|
mv $out/libexec/netdata/plugins.d/cgroup-network \
|
|
|
|
$out/libexec/netdata/plugins.d/cgroup-network.org
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
2023-11-16 04:20:00 +00:00
|
|
|
${lib.optionalString withSystemdJournal ''
|
|
|
|
mv $out/libexec/netdata/plugins.d/systemd-journal.plugin \
|
|
|
|
$out/libexec/netdata/plugins.d/systemd-journal.plugin.org
|
|
|
|
''}
|
2023-02-02 18:25:31 +00:00
|
|
|
${lib.optionalString withIpmi ''
|
2020-04-24 23:36:52 +00:00
|
|
|
mv $out/libexec/netdata/plugins.d/freeipmi.plugin \
|
|
|
|
$out/libexec/netdata/plugins.d/freeipmi.plugin.org
|
|
|
|
''}
|
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
preConfigure = lib.optionalString (!stdenv.isDarwin) ''
|
2020-04-24 23:36:52 +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"
|
2022-05-18 14:49:53 +00:00
|
|
|
"--disable-ebpf"
|
2022-07-14 12:49:19 +00:00
|
|
|
"--with-jemalloc=${jemalloc}"
|
2023-11-16 04:20:00 +00:00
|
|
|
] ++ lib.optionals (withSystemdJournal) [
|
|
|
|
"--enable-plugin-systemd-journal"
|
2023-02-02 18:25:31 +00:00
|
|
|
] ++ lib.optionals (!withDBengine) [
|
2022-07-14 12:49:19 +00:00
|
|
|
"--disable-dbengine"
|
2023-02-02 18:25:31 +00:00
|
|
|
] ++ lib.optionals (!withCloud) [
|
2022-07-14 12:49:19 +00:00
|
|
|
"--disable-cloud"
|
2023-10-09 19:29:22 +00:00
|
|
|
] ++ lib.optionals (!withCloudUi) [
|
|
|
|
"--disable-cloud-ui"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postFixup = ''
|
2023-11-16 04:20:00 +00:00
|
|
|
# remove once https://github.com/netdata/netdata/pull/16300 merged
|
|
|
|
substituteInPlace $out/bin/netdata-claim.sh \
|
|
|
|
--replace /bin/echo echo
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
wrapProgram $out/bin/netdata-claim.sh --prefix PATH : ${lib.makeBinPath [ openssl ]}
|
2023-03-24 00:07:29 +00:00
|
|
|
wrapProgram $out/libexec/netdata/plugins.d/cgroup-network-helper.sh --prefix PATH : ${lib.makeBinPath [ bash ]}
|
2023-08-10 07:59:29 +00:00
|
|
|
wrapProgram $out/bin/netdatacli --set NETDATA_PIPENAME /run/netdata/ipc
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
enableParallelBuild = true;
|
|
|
|
|
2021-09-22 15:38:15 +00:00
|
|
|
passthru = {
|
|
|
|
inherit withIpmi;
|
|
|
|
tests.netdata = nixosTests.netdata;
|
|
|
|
};
|
2020-09-25 04:45:31 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
meta = with lib; {
|
2023-01-20 10:41:00 +00:00
|
|
|
broken = stdenv.isDarwin || stdenv.buildPlatform != stdenv.hostPlatform;
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Real-time performance monitoring tool";
|
2020-09-25 04:45:31 +00:00
|
|
|
homepage = "https://www.netdata.cloud/";
|
2023-07-15 17:15:38 +00:00
|
|
|
changelog = "https://github.com/netdata/netdata/releases/tag/v${version}";
|
2023-10-09 19:29:22 +00:00
|
|
|
license = [ licenses.gpl3Plus ]
|
|
|
|
++ lib.optionals (withCloudUi) [ licenses.ncul1 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.unix;
|
2023-03-24 00:07:29 +00:00
|
|
|
maintainers = with maintainers; [ raitobezarius ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|