39 withConnPrometheus ? false,
40 withConnPubSub ? false,
45 withIpmi ? (stdenv.hostPlatform.isLinux),
46 withNetfilter ? (stdenv.hostPlatform.isLinux),
47 withNetworkViewer ? (stdenv.hostPlatform.isLinux),
49 withSystemdJournal ? (stdenv.hostPlatform.isLinux),
53 stdenv' = if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv;
55 stdenv'.mkDerivation (finalAttrs: {
59 src = fetchFromGitHub {
62 rev = "v${finalAttrs.version}";
65 "sha256-PCaY6J3X4zUUJ8kRCGmLLbk2Pkp5CnH3rxOaoAdsKG4="
66 # we delete the v2 GUI after fetching
68 "sha256-W4g/ns+XfBSf6iACIW+6lfzZJLMktTfe5/n3egL27XE=";
69 fetchSubmodules = true;
71 # Remove v2 dashboard distributed under NCUL1. Make sure an empty
72 # Makefile.am exists, as autoreconf will get confused otherwise.
73 postFetch = lib.optionalString (!withCloudUi) ''
74 rm -rf $out/src/web/gui/v2/*
75 touch $out/src/web/gui/v2/Makefile.am
87 ] ++ lib.optionals withCups [ cups.dev ];
88 # bash is only used to rewrite shebangs
99 ++ lib.optionals stdenv.hostPlatform.isDarwin (
100 with darwin.apple_sdk.frameworks;
107 ++ lib.optionals (stdenv.hostPlatform.isLinux) [
112 ++ lib.optionals withCups [ cups ]
113 ++ lib.optionals withDBengine [ lz4 ]
114 ++ lib.optionals withIpmi [ freeipmi ]
115 ++ lib.optionals withNetfilter [
119 ++ lib.optionals withConnPubSub [
123 ++ lib.optionals withConnPrometheus [ snappy ]
124 ++ lib.optionals withEbpf [
128 ++ lib.optionals (withCloud || withConnPrometheus) [ protobuf ]
129 ++ lib.optionals withSystemdJournal [ systemd ]
130 ++ lib.optionals withSsl [ openssl ];
133 # Allow ndsudo to use non-hardcoded `PATH`
134 # See https://github.com/netdata/netdata/pull/17377#issuecomment-2183017868
135 # https://github.com/netdata/netdata/security/advisories/GHSA-pmhq-4cxq-wj93
136 ./ndsudo-fix-path.patch
137 # Allow building without non-free v2 dashboard.
138 ./dashboard-v2-removal.patch
141 # Guard against unused build-time development inputs in closure. Without
142 # the ./skip-CONFIGURE_COMMAND.patch patch the closure retains inputs up
143 # to bootstrap tools:
144 # https://github.com/NixOS/nixpkgs/pull/175719
145 # We pick zlib.dev as a simple canary package with pkg-config input.
146 disallowedReferences = lib.optional (!withDebug) zlib.dev;
148 donStrip = withDebug;
149 env.NIX_CFLAGS_COMPILE = lib.optionalString withDebug "-O1 -ggdb -DNETDATA_INTERNAL_CHECKS=1";
153 # Relocate one folder above.
156 + lib.optionalString (stdenv.hostPlatform.isLinux) ''
157 # rename this plugin so netdata will look for setuid wrapper
158 mv $out/libexec/netdata/plugins.d/apps.plugin \
159 $out/libexec/netdata/plugins.d/apps.plugin.org
160 mv $out/libexec/netdata/plugins.d/cgroup-network \
161 $out/libexec/netdata/plugins.d/cgroup-network.org
162 mv $out/libexec/netdata/plugins.d/perf.plugin \
163 $out/libexec/netdata/plugins.d/perf.plugin.org
164 mv $out/libexec/netdata/plugins.d/slabinfo.plugin \
165 $out/libexec/netdata/plugins.d/slabinfo.plugin.org
166 mv $out/libexec/netdata/plugins.d/debugfs.plugin \
167 $out/libexec/netdata/plugins.d/debugfs.plugin.org
168 ${lib.optionalString withSystemdJournal ''
169 mv $out/libexec/netdata/plugins.d/systemd-journal.plugin \
170 $out/libexec/netdata/plugins.d/systemd-journal.plugin.org
172 ${lib.optionalString withIpmi ''
173 mv $out/libexec/netdata/plugins.d/freeipmi.plugin \
174 $out/libexec/netdata/plugins.d/freeipmi.plugin.org
176 ${lib.optionalString withNetworkViewer ''
177 mv $out/libexec/netdata/plugins.d/network-viewer.plugin \
178 $out/libexec/netdata/plugins.d/network-viewer.plugin.org
180 ${lib.optionalString (!withCloudUi) ''
181 rm -rf $out/share/netdata/web/index.html
182 cp $out/share/netdata/web/v1/index.html $out/share/netdata/web/index.html
187 export GOCACHE=$TMPDIR/go-cache
188 export GOPATH=$TMPDIR/go
191 substituteInPlace packaging/cmake/Modules/NetdataGoTools.cmake \
193 'GOPROXY=https://proxy.golang.org' \
194 'GOPROXY=file://${finalAttrs.passthru.netdata-go-modules}'
196 # Prevent the path to be caught into the Nix store path.
197 substituteInPlace CMakeLists.txt \
198 --replace-fail 'set(CACHE_DIR "''${NETDATA_RUNTIME_PREFIX}/var/cache/netdata")' 'set(CACHE_DIR "/var/cache/netdata")' \
199 --replace-fail 'set(CONFIG_DIR "''${NETDATA_RUNTIME_PREFIX}/etc/netdata")' 'set(CONFIG_DIR "/etc/netdata")' \
200 --replace-fail 'set(LIBCONFIG_DIR "''${NETDATA_RUNTIME_PREFIX}/usr/lib/netdata/conf.d")' 'set(LIBCONFIG_DIR "${placeholder "out"}/share/netdata/conf.d")' \
201 --replace-fail 'set(LOG_DIR "''${NETDATA_RUNTIME_PREFIX}/var/log/netdata")' 'set(LOG_DIR "/var/log/netdata")' \
202 --replace-fail 'set(PLUGINS_DIR "''${NETDATA_RUNTIME_PREFIX}/usr/libexec/netdata/plugins.d")' 'set(PLUGINS_DIR "${placeholder "out"}/libexec/netdata/plugins.d")' \
203 --replace-fail 'set(VARLIB_DIR "''${NETDATA_RUNTIME_PREFIX}/var/lib/netdata")' 'set(VARLIB_DIR "/var/lib/netdata")' \
204 --replace-fail 'set(pkglibexecdir_POST "''${NETDATA_RUNTIME_PREFIX}/usr/libexec/netdata")' 'set(pkglibexecdir_POST "${placeholder "out"}/libexec/netdata")' \
205 --replace-fail 'set(localstatedir_POST "''${NETDATA_RUNTIME_PREFIX}/var")' 'set(localstatedir_POST "/var")' \
206 --replace-fail 'set(sbindir_POST "''${NETDATA_RUNTIME_PREFIX}/''${BINDIR}")' 'set(sbindir_POST "${placeholder "out"}/bin")' \
207 --replace-fail 'set(configdir_POST "''${NETDATA_RUNTIME_PREFIX}/etc/netdata")' 'set(configdir_POST "/etc/netdata")' \
208 --replace-fail 'set(libconfigdir_POST "''${NETDATA_RUNTIME_PREFIX}/usr/lib/netdata/conf.d")' 'set(libconfigdir_POST "${placeholder "out"}/share/netdata/conf.d")' \
209 --replace-fail 'set(cachedir_POST "''${NETDATA_RUNTIME_PREFIX}/var/cache/netdata")' 'set(libconfigdir_POST "/var/cache/netdata")' \
210 --replace-fail 'set(registrydir_POST "''${NETDATA_RUNTIME_PREFIX}/var/lib/netdata/registry")' 'set(registrydir_POST "/var/lib/netdata/registry")' \
211 --replace-fail 'set(varlibdir_POST "''${NETDATA_RUNTIME_PREFIX}/var/lib/netdata")' 'set(varlibdir_POST "/var/lib/netdata")'
215 "-DWEB_DIR=share/netdata/web"
216 (lib.cmakeBool "ENABLE_CLOUD" withCloud)
217 # ACLK is agent cloud link.
218 (lib.cmakeBool "ENABLE_ACLK" withCloud)
219 (lib.cmakeBool "ENABLE_DASHBOARD_V2" withCloudUi)
220 (lib.cmakeBool "ENABLE_DBENGINE" withDBengine)
221 (lib.cmakeBool "ENABLE_PLUGIN_FREEIPMI" withIpmi)
222 (lib.cmakeBool "ENABLE_PLUGIN_SYSTEMD_JOURNAL" withSystemdJournal)
223 (lib.cmakeBool "ENABLE_PLUGIN_NETWORK_VIEWER" withNetworkViewer)
224 (lib.cmakeBool "ENABLE_PLUGIN_EBPF" withEbpf)
225 (lib.cmakeBool "ENABLE_PLUGIN_XENSTAT" false)
226 (lib.cmakeBool "ENABLE_PLUGIN_CUPS" withCups)
227 (lib.cmakeBool "ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE" withConnPrometheus)
228 (lib.cmakeBool "ENABLE_JEMALLOC" true)
229 # Suggested by upstream.
234 wrapProgram $out/bin/netdata-claim.sh --prefix PATH : ${lib.makeBinPath [ openssl ]}
235 wrapProgram $out/libexec/netdata/plugins.d/cgroup-network-helper.sh --prefix PATH : ${lib.makeBinPath [ bash ]}
236 wrapProgram $out/bin/netdatacli --set NETDATA_PIPENAME /run/netdata/ipc
238 # Time to cleanup the output directory.
240 cp $out/etc/netdata/edit-config $out/bin/netdata-edit-config
241 mv $out/lib/netdata/conf.d $out/share/netdata/conf.d
242 rm -rf $out/{var,usr,etc}
245 enableParallelBuilding = true;
250 pname = "netdata-go-plugins";
251 inherit (finalAttrs) version src;
253 sourceRoot = "${finalAttrs.src.name}/src/go/plugin/go.d";
255 vendorHash = "sha256-NZ1tg+lvXNgypqmjjb5f7dHH6DIA9VOa4PMM4eq11n0=";
262 "-X main.version=${finalAttrs.version}"
265 passthru.tests = tests;
266 meta = finalAttrs.meta // {
267 description = "Netdata orchestrator for data collection modules written in Go";
268 mainProgram = "godplugin";
269 license = lib.licenses.gpl3Only;
272 inherit withIpmi withNetworkViewer;
273 tests.netdata = nixosTests.netdata;
277 broken = stdenv.buildPlatform != stdenv.hostPlatform || withEbpf;
278 description = "Real-time performance monitoring tool";
279 homepage = "https://www.netdata.cloud/";
280 changelog = "https://github.com/netdata/netdata/releases/tag/v${version}";
281 license = [ licenses.gpl3Plus ] ++ lib.optionals (withCloudUi) [ licenses.ncul1 ];
282 platforms = platforms.unix;