2024-06-24 18:47:55 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, pkg-config, makeWrapper
|
2020-04-24 23:36:52 +00:00
|
|
|
, CoreFoundation, IOKit, libossp_uuid
|
2020-09-25 04:45:31 +00:00
|
|
|
, nixosTests
|
2024-06-24 18:47:55 +00:00
|
|
|
, bash, curl, jemalloc, json_c, libuv, zlib, libyaml, libelf, libbpf
|
2022-07-14 12:49:19 +00:00
|
|
|
, libcap, libuuid, lm_sensors, protobuf
|
2024-06-24 18:47:55 +00:00
|
|
|
, go, buildGoModule, ninja
|
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
|
2024-06-24 18:47:55 +00:00
|
|
|
, withEbpf ? false
|
|
|
|
, withNetworkViewer ? (!stdenv.isDarwin)
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-03-08 16:32:21 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2024-06-24 18:47:55 +00:00
|
|
|
version = "1.45.4";
|
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-06-24 18:47:55 +00:00
|
|
|
then "sha256-g/wxKtpNsDw/ZaUokdip39enQHMysJE6pYGsApuL4po="
|
|
|
|
# we delete the v2 GUI after fetching
|
|
|
|
else "sha256-Mkrmvdr19sWzFOkdpt46mcsbA3CNpXy4w8um95xaWlo=";
|
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) ''
|
2024-06-24 18:47:55 +00:00
|
|
|
rm -rf $out/src/web/gui/v2/*
|
|
|
|
touch $out/src/web/gui/v2/Makefile.am
|
2023-10-09 19:29:22 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
2024-06-24 18:47:55 +00:00
|
|
|
nativeBuildInputs = [ cmake pkg-config makeWrapper go ninja ];
|
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 ]
|
2024-06-24 18:47:55 +00:00
|
|
|
++ lib.optionals withEbpf [ libelf libbpf ]
|
2023-02-02 18:25:31 +00:00
|
|
|
++ 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 = [
|
2023-10-09 19:29:22 +00:00
|
|
|
# Allow building without non-free v2 dashboard.
|
|
|
|
(fetchpatch {
|
2024-06-24 18:47:55 +00:00
|
|
|
url = "https://github.com/netdata/netdata/pull/17240/commits/b108df72281633234b731b223d99ec99f1d36adf.patch";
|
|
|
|
hash = "sha256-tgsnbNY0pxFU3bz1J1qPaAeVsozsk2bpHV2mNy8A9is=";
|
|
|
|
})
|
|
|
|
# Allow for go.d plugins to access the right directory.
|
|
|
|
# Can be removed once > v1.45.4 is released
|
|
|
|
# https://github.com/netdata/netdata/pull/17661
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://patch-diff.githubusercontent.com/raw/netdata/netdata/pull/17661.patch";
|
|
|
|
sha256 = "sha256-j+mrwkibQio2KO8UnV7sxzCoHmkcsalHNzP+YvrRz74=";
|
2023-10-09 19:29:22 +00:00
|
|
|
})
|
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 = ''
|
2024-06-24 18:47:55 +00:00
|
|
|
# Relocate one folder above.
|
|
|
|
mv $out/usr/* $out/
|
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
|
2024-06-24 18:47:55 +00:00
|
|
|
mv $out/libexec/netdata/plugins.d/debugfs.plugin \
|
|
|
|
$out/libexec/netdata/plugins.d/debugfs.plugin.org
|
|
|
|
mv $out/libexec/netdata/plugins.d/logs-management.plugin \
|
|
|
|
$out/libexec/netdata/plugins.d/logs-management.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
|
|
|
|
''}
|
2024-06-24 18:47:55 +00:00
|
|
|
${lib.optionalString withNetworkViewer ''
|
|
|
|
mv $out/libexec/netdata/plugins.d/network-viewer.plugin \
|
|
|
|
$out/libexec/netdata/plugins.d/network-viewer.plugin.org
|
|
|
|
''}
|
|
|
|
${lib.optionalString (!withCloudUi) ''
|
|
|
|
rm -rf $out/share/netdata/web/index.html
|
|
|
|
cp $out/share/netdata/web/v1/index.html $out/share/netdata/web/index.html
|
|
|
|
''}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
preConfigure = lib.optionalString (!stdenv.isDarwin) ''
|
2024-06-24 18:47:55 +00:00
|
|
|
substituteInPlace src/collectors/python.d.plugin/python_modules/third_party/lm_sensors.py \
|
|
|
|
--replace-fail 'ctypes.util.find_library("sensors")' '"${lm_sensors.out}/lib/libsensors${stdenv.hostPlatform.extensions.sharedLibrary}"'
|
|
|
|
'' + ''
|
|
|
|
export GOCACHE=$TMPDIR/go-cache
|
|
|
|
export GOPATH=$TMPDIR/go
|
|
|
|
export GOPROXY=file://${passthru.netdata-go-modules}
|
|
|
|
export GOSUMDB=off
|
|
|
|
|
|
|
|
# Prevent the path to be caught into the Nix store path.
|
|
|
|
substituteInPlace CMakeLists.txt \
|
|
|
|
--replace-fail 'set(CACHE_DIR "''${CMAKE_INSTALL_PREFIX}/var/cache/netdata")' 'set(CACHE_DIR "/var/cache/netdata")' \
|
|
|
|
--replace-fail 'set(CONFIG_DIR "''${CMAKE_INSTALL_PREFIX}/etc/netdata")' 'set(CONFIG_DIR "/etc/netdata")' \
|
|
|
|
--replace-fail 'set(LIBCONFIG_DIR "''${CMAKE_INSTALL_PREFIX}/usr/lib/netdata/conf.d")' 'set(LIBCONFIG_DIR "${placeholder "out"}/share/netdata/conf.d")' \
|
|
|
|
--replace-fail 'set(LOG_DIR "''${CMAKE_INSTALL_PREFIX}/var/log/netdata")' 'set(LOG_DIR "/var/log/netdata")' \
|
|
|
|
--replace-fail 'set(PLUGINS_DIR "''${CMAKE_INSTALL_PREFIX}/usr/libexec/netdata/plugins.d")' 'set(PLUGINS_DIR "${placeholder "out"}/libexec/netdata/plugins.d")' \
|
|
|
|
--replace-fail 'set(VARLIB_DIR "''${CMAKE_INSTALL_PREFIX}/var/lib/netdata")' 'set(VARLIB_DIR "/var/lib/netdata")' \
|
|
|
|
--replace-fail 'set(pkglibexecdir_POST "''${CMAKE_INSTALL_PREFIX}/usr/libexec/netdata")' 'set(pkglibexecdir_POST "${placeholder "out"}/libexec/netdata")' \
|
|
|
|
--replace-fail 'set(localstatedir_POST "''${CMAKE_INSTALL_PREFIX}/var")' 'set(localstatedir_POST "/var")' \
|
|
|
|
--replace-fail 'set(sbindir_POST "''${CMAKE_INSTALL_PREFIX}/usr/sbin")' 'set(sbindir_POST "${placeholder "out"}/bin")' \
|
|
|
|
--replace-fail 'set(configdir_POST "''${CMAKE_INSTALL_PREFIX}/etc/netdata")' 'set(configdir_POST "/etc/netdata")' \
|
|
|
|
--replace-fail 'set(libconfigdir_POST "''${CMAKE_INSTALL_PREFIX}/usr/lib/netdata/conf.d")' 'set(libconfigdir_POST "${placeholder "out"}/share/netdata/conf.d")' \
|
|
|
|
--replace-fail 'set(cachedir_POST "''${CMAKE_INSTALL_PREFIX}/var/cache/netdata")' 'set(libconfigdir_POST "/var/cache/netdata")' \
|
|
|
|
--replace-fail 'set(registrydir_POST "''${CMAKE_INSTALL_PREFIX}/var/lib/netdata/registry")' 'set(registrydir_POST "/var/lib/netdata/registry")' \
|
|
|
|
--replace-fail 'set(varlibdir_POST "''${CMAKE_INSTALL_PREFIX}/var/lib/netdata")' 'set(varlibdir_POST "/var/lib/netdata")'
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2024-06-24 18:47:55 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DWEB_DIR=share/netdata/web"
|
|
|
|
(lib.cmakeBool "ENABLE_CLOUD" withCloud)
|
|
|
|
# ACLK is agent cloud link.
|
|
|
|
(lib.cmakeBool "ENABLE_ACLK" withCloud)
|
|
|
|
(lib.cmakeBool "ENABLE_DASHBOARD_V2" withCloudUi)
|
|
|
|
(lib.cmakeBool "ENABLE_DBENGINE" withDBengine)
|
|
|
|
(lib.cmakeBool "ENABLE_PLUGIN_FREEIPMI" withIpmi)
|
|
|
|
(lib.cmakeBool "ENABLE_PLUGIN_SYSTEMD_JOURNAL" withSystemdJournal)
|
|
|
|
(lib.cmakeBool "ENABLE_PLUGIN_NETWORK_VIEWER" withNetworkViewer)
|
|
|
|
(lib.cmakeBool "ENABLE_PLUGIN_EBPF" withEbpf)
|
|
|
|
(lib.cmakeBool "ENABLE_PLUGIN_XENSTAT" false)
|
|
|
|
(lib.cmakeBool "ENABLE_PLUGIN_CUPS" withCups)
|
|
|
|
(lib.cmakeBool "ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE" withConnPrometheus)
|
|
|
|
(lib.cmakeBool "ENABLE_JEMALLOC" true)
|
|
|
|
# Suggested by upstream.
|
|
|
|
"-G Ninja"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postFixup = ''
|
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
|
2024-06-24 18:47:55 +00:00
|
|
|
|
|
|
|
# Time to cleanup the output directory.
|
|
|
|
unlink $out/sbin
|
|
|
|
cp $out/etc/netdata/edit-config $out/bin/netdata-edit-config
|
|
|
|
mv $out/lib/netdata/conf.d $out/share/netdata/conf.d
|
|
|
|
rm -rf $out/{var,usr,etc}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
enableParallelBuild = true;
|
|
|
|
|
2024-06-24 18:47:55 +00:00
|
|
|
passthru = rec {
|
|
|
|
netdata-go-modules = (buildGoModule {
|
|
|
|
pname = "netdata-go-plugins";
|
|
|
|
inherit version src;
|
|
|
|
|
|
|
|
sourceRoot = "${src.name}/src/go/collectors/go.d.plugin";
|
|
|
|
|
|
|
|
vendorHash = "sha256-KO+xMk6fpZCYRyxxKrsGfOHJ2bwjBaSmkgz1jIUHaZs=";
|
|
|
|
doCheck = false;
|
|
|
|
proxyVendor = true;
|
|
|
|
|
|
|
|
ldflags = [ "-s" "-w" "-X main.version=${version}" ];
|
|
|
|
|
|
|
|
passthru.tests = tests;
|
|
|
|
meta = meta // {
|
|
|
|
description = "Netdata orchestrator for data collection modules written in Go";
|
|
|
|
mainProgram = "godplugin";
|
|
|
|
license = lib.licenses.gpl3Only;
|
|
|
|
};
|
|
|
|
}).goModules;
|
|
|
|
inherit withIpmi withNetworkViewer;
|
2021-09-22 15:38:15 +00:00
|
|
|
tests.netdata = nixosTests.netdata;
|
|
|
|
};
|
2020-09-25 04:45:31 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
meta = with lib; {
|
2024-06-24 18:47:55 +00:00
|
|
|
broken = stdenv.isDarwin || stdenv.buildPlatform != stdenv.hostPlatform || withEbpf;
|
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;
|
2024-06-24 18:47:55 +00:00
|
|
|
maintainers = [ ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|