From 3dbab8acbb9c5a94a722adefe0d6b910f2867949 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 12 Sep 2024 18:21:37 -0500 Subject: [PATCH 1/4] netdata: format --- pkgs/tools/system/netdata/default.nix | 229 +++++++++++++++++--------- 1 file changed, 149 insertions(+), 80 deletions(-) diff --git a/pkgs/tools/system/netdata/default.nix b/pkgs/tools/system/netdata/default.nix index 84050ab400dc..c5dd4a9c016c 100644 --- a/pkgs/tools/system/netdata/default.nix +++ b/pkgs/tools/system/netdata/default.nix @@ -1,24 +1,54 @@ -{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, makeWrapper -, CoreFoundation, IOKit, libossp_uuid -, nixosTests -, bash, curl, jemalloc, json_c, libuv, zlib, libyaml, libelf, libbpf -, libcap, libuuid, lm_sensors, protobuf -, go, buildGoModule, ninja -, withCups ? false, cups -, withDBengine ? true, lz4 -, withIpmi ? (!stdenv.isDarwin), freeipmi -, withNetfilter ? (!stdenv.isDarwin), libmnl, libnetfilter_acct -, withCloud ? false -, withCloudUi ? false -, withConnPubSub ? false, google-cloud-cpp, grpc -, withConnPrometheus ? false, snappy -, withSsl ? true, openssl -, withSystemdJournal ? (!stdenv.isDarwin), systemd -, withDebug ? false -, withEbpf ? false -, withNetworkViewer ? (!stdenv.isDarwin) +{ + lib, + stdenv, + fetchFromGitHub, + CoreFoundation, + IOKit, + bash, + buildGoModule, + cmake, + cups, + curl, + freeipmi, + go, + google-cloud-cpp, + grpc, + jemalloc, + json_c, + libbpf, + libcap, + libelf, + libmnl, + libnetfilter_acct, + libossp_uuid, + libuuid, + libuv, + libyaml, + lm_sensors, + lz4, + makeWrapper, + ninja, + nixosTests, + openssl, + pkg-config, + protobuf, + snappy, + systemd, + withCloud ? false, + withCloudUi ? false, + withConnPrometheus ? false, + withConnPubSub ? false, + withCups ? false, + withDBengine ? true, + withDebug ? false, + withEbpf ? false, + withIpmi ? (!stdenv.isDarwin), + withNetfilter ? (!stdenv.isDarwin), + withNetworkViewer ? (!stdenv.isDarwin), + withSsl ? true, + withSystemdJournal ? (!stdenv.isDarwin), + zlib, }: - stdenv.mkDerivation rec { version = "1.47.0"; pname = "netdata"; @@ -27,10 +57,12 @@ stdenv.mkDerivation rec { owner = "netdata"; repo = "netdata"; rev = "v${version}"; - hash = if withCloudUi - then "sha256-eMapy4HQaEblDfZt2uVSfBWRlkstX7TxZDBgSv5bW/I=" + hash = + if withCloudUi then + "sha256-eMapy4HQaEblDfZt2uVSfBWRlkstX7TxZDBgSv5bW/I=" # we delete the v2 GUI after fetching - else "sha256-Gx7u3Owh/fVAnSw91xfdcmyx4m+bvQAvDaUxzXQ36/0="; + else + "sha256-Gx7u3Owh/fVAnSw91xfdcmyx4m+bvQAvDaUxzXQ36/0="; fetchSubmodules = true; # Remove v2 dashboard distributed under NCUL1. Make sure an empty @@ -43,19 +75,50 @@ stdenv.mkDerivation rec { strictDeps = true; - nativeBuildInputs = [ cmake pkg-config makeWrapper go ninja ] - ++ lib.optionals withCups [ cups.dev ]; + nativeBuildInputs = [ + cmake + pkg-config + makeWrapper + go + ninja + ] ++ lib.optionals withCups [ cups.dev ]; # bash is only used to rewrite shebangs - buildInputs = [ bash curl jemalloc json_c libuv zlib libyaml lm_sensors ] - ++ lib.optionals stdenv.isDarwin [ CoreFoundation IOKit libossp_uuid ] - ++ lib.optionals (!stdenv.isDarwin) [ libcap libuuid ] + buildInputs = + [ + bash + curl + jemalloc + json_c + libuv + zlib + libyaml + lm_sensors + ] + ++ 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 withNetfilter [ + libmnl + libnetfilter_acct + ] + ++ lib.optionals withConnPubSub [ + google-cloud-cpp + grpc + ] ++ lib.optionals withConnPrometheus [ snappy ] - ++ lib.optionals withEbpf [ libelf libbpf ] + ++ lib.optionals withEbpf [ + libelf + libbpf + ] ++ lib.optionals (withCloud || withConnPrometheus) [ protobuf ] ++ lib.optionals withSystemdJournal [ systemd ] ++ lib.optionals withSsl [ openssl ]; @@ -79,38 +142,40 @@ stdenv.mkDerivation rec { donStrip = withDebug; env.NIX_CFLAGS_COMPILE = lib.optionalString withDebug "-O1 -ggdb -DNETDATA_INTERNAL_CHECKS=1"; - postInstall = '' - # Relocate one folder above. - mv $out/usr/* $out/ - '' + lib.optionalString (!stdenv.isDarwin) '' - # 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 - 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 - mv $out/libexec/netdata/plugins.d/debugfs.plugin \ - $out/libexec/netdata/plugins.d/debugfs.plugin.org - ${lib.optionalString withSystemdJournal '' - mv $out/libexec/netdata/plugins.d/systemd-journal.plugin \ - $out/libexec/netdata/plugins.d/systemd-journal.plugin.org - ''} - ${lib.optionalString withIpmi '' - mv $out/libexec/netdata/plugins.d/freeipmi.plugin \ - $out/libexec/netdata/plugins.d/freeipmi.plugin.org - ''} - ${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 - ''} - ''; + postInstall = + '' + # Relocate one folder above. + mv $out/usr/* $out/ + '' + + lib.optionalString (!stdenv.isDarwin) '' + # 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 + 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 + mv $out/libexec/netdata/plugins.d/debugfs.plugin \ + $out/libexec/netdata/plugins.d/debugfs.plugin.org + ${lib.optionalString withSystemdJournal '' + mv $out/libexec/netdata/plugins.d/systemd-journal.plugin \ + $out/libexec/netdata/plugins.d/systemd-journal.plugin.org + ''} + ${lib.optionalString withIpmi '' + mv $out/libexec/netdata/plugins.d/freeipmi.plugin \ + $out/libexec/netdata/plugins.d/freeipmi.plugin.org + ''} + ${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 + ''} + ''; preConfigure = lib.optionalString (!stdenv.isDarwin) '' export GOCACHE=$TMPDIR/go-cache @@ -174,25 +239,30 @@ stdenv.mkDerivation rec { enableParallelBuild = true; passthru = rec { - netdata-go-modules = (buildGoModule { - pname = "netdata-go-plugins"; - inherit version src; + netdata-go-modules = + (buildGoModule { + pname = "netdata-go-plugins"; + inherit version src; - sourceRoot = "${src.name}/src/go/plugin/go.d"; + sourceRoot = "${src.name}/src/go/plugin/go.d"; - vendorHash = "sha256-NZ1tg+lvXNgypqmjjb5f7dHH6DIA9VOa4PMM4eq11n0="; - doCheck = false; - proxyVendor = true; + vendorHash = "sha256-NZ1tg+lvXNgypqmjjb5f7dHH6DIA9VOa4PMM4eq11n0="; + doCheck = false; + proxyVendor = true; - ldflags = [ "-s" "-w" "-X main.version=${version}" ]; + 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; + 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; tests.netdata = nixosTests.netdata; }; @@ -202,8 +272,7 @@ stdenv.mkDerivation rec { description = "Real-time performance monitoring tool"; homepage = "https://www.netdata.cloud/"; changelog = "https://github.com/netdata/netdata/releases/tag/v${version}"; - license = [ licenses.gpl3Plus ] - ++ lib.optionals (withCloudUi) [ licenses.ncul1 ]; + license = [ licenses.gpl3Plus ] ++ lib.optionals (withCloudUi) [ licenses.ncul1 ]; platforms = platforms.unix; maintainers = [ ]; }; From 3b6197558a267cd6860c68db2e1742286cd2edb5 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 12 Sep 2024 18:23:53 -0500 Subject: [PATCH 2/4] netdata: cleanup rec --- pkgs/tools/system/netdata/default.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/tools/system/netdata/default.nix b/pkgs/tools/system/netdata/default.nix index c5dd4a9c016c..1af6c4d9cb8a 100644 --- a/pkgs/tools/system/netdata/default.nix +++ b/pkgs/tools/system/netdata/default.nix @@ -49,14 +49,14 @@ withSystemdJournal ? (!stdenv.isDarwin), zlib, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { version = "1.47.0"; pname = "netdata"; src = fetchFromGitHub { owner = "netdata"; repo = "netdata"; - rev = "v${version}"; + rev = "v${finalAttrs.version}"; hash = if withCloudUi then "sha256-eMapy4HQaEblDfZt2uVSfBWRlkstX7TxZDBgSv5bW/I=" @@ -185,7 +185,7 @@ stdenv.mkDerivation rec { substituteInPlace packaging/cmake/Modules/NetdataGoTools.cmake \ --replace-fail \ 'GOPROXY=https://proxy.golang.org' \ - 'GOPROXY=file://${passthru.netdata-go-modules}' + 'GOPROXY=file://${finalAttrs.passthru.netdata-go-modules}' # Prevent the path to be caught into the Nix store path. substituteInPlace CMakeLists.txt \ @@ -242,9 +242,9 @@ stdenv.mkDerivation rec { netdata-go-modules = (buildGoModule { pname = "netdata-go-plugins"; - inherit version src; + inherit (finalAttrs) version src; - sourceRoot = "${src.name}/src/go/plugin/go.d"; + sourceRoot = "${finalAttrs.src.name}/src/go/plugin/go.d"; vendorHash = "sha256-NZ1tg+lvXNgypqmjjb5f7dHH6DIA9VOa4PMM4eq11n0="; doCheck = false; @@ -253,11 +253,11 @@ stdenv.mkDerivation rec { ldflags = [ "-s" "-w" - "-X main.version=${version}" + "-X main.version=${finalAttrs.version}" ]; passthru.tests = tests; - meta = meta // { + meta = finalAttrs.meta // { description = "Netdata orchestrator for data collection modules written in Go"; mainProgram = "godplugin"; license = lib.licenses.gpl3Only; @@ -276,4 +276,4 @@ stdenv.mkDerivation rec { platforms = platforms.unix; maintainers = [ ]; }; -} +}) From da31ab50f3ad9ed653423890137a7b453aa2dd01 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 12 Sep 2024 18:37:55 -0500 Subject: [PATCH 3/4] netdata: fix darwin --- pkgs/tools/system/netdata/default.nix | 40 +++++++++++++++------------ pkgs/top-level/all-packages.nix | 1 - 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/pkgs/tools/system/netdata/default.nix b/pkgs/tools/system/netdata/default.nix index 1af6c4d9cb8a..9db4e7756858 100644 --- a/pkgs/tools/system/netdata/default.nix +++ b/pkgs/tools/system/netdata/default.nix @@ -2,13 +2,12 @@ lib, stdenv, fetchFromGitHub, - CoreFoundation, - IOKit, bash, buildGoModule, cmake, cups, curl, + darwin, freeipmi, go, google-cloud-cpp, @@ -30,6 +29,7 @@ ninja, nixosTests, openssl, + overrideSDK, pkg-config, protobuf, snappy, @@ -42,14 +42,17 @@ withDBengine ? true, withDebug ? false, withEbpf ? false, - withIpmi ? (!stdenv.isDarwin), - withNetfilter ? (!stdenv.isDarwin), - withNetworkViewer ? (!stdenv.isDarwin), + withIpmi ? (stdenv.isLinux), + withNetfilter ? (stdenv.isLinux), + withNetworkViewer ? (stdenv.isLinux), withSsl ? true, - withSystemdJournal ? (!stdenv.isDarwin), + withSystemdJournal ? (stdenv.isLinux), zlib, }: -stdenv.mkDerivation (finalAttrs: { +let + stdenv' = if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv; +in +stdenv'.mkDerivation (finalAttrs: { version = "1.47.0"; pname = "netdata"; @@ -92,16 +95,19 @@ stdenv.mkDerivation (finalAttrs: { libuv zlib libyaml - lm_sensors ] - ++ lib.optionals stdenv.isDarwin [ - CoreFoundation - IOKit - libossp_uuid - ] - ++ lib.optionals (!stdenv.isDarwin) [ + ++ lib.optionals stdenv.isDarwin ( + with darwin.apple_sdk.frameworks; + [ + CoreFoundation + IOKit + libossp_uuid + ] + ) + ++ lib.optionals (stdenv.isLinux) [ libcap libuuid + lm_sensors ] ++ lib.optionals withCups [ cups ] ++ lib.optionals withDBengine [ lz4 ] @@ -147,7 +153,7 @@ stdenv.mkDerivation (finalAttrs: { # Relocate one folder above. mv $out/usr/* $out/ '' - + lib.optionalString (!stdenv.isDarwin) '' + + lib.optionalString (stdenv.isLinux) '' # 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 @@ -177,7 +183,7 @@ stdenv.mkDerivation (finalAttrs: { ''} ''; - preConfigure = lib.optionalString (!stdenv.isDarwin) '' + preConfigure = '' export GOCACHE=$TMPDIR/go-cache export GOPATH=$TMPDIR/go export GOSUMDB=off @@ -268,7 +274,7 @@ stdenv.mkDerivation (finalAttrs: { }; meta = with lib; { - broken = stdenv.isDarwin || stdenv.buildPlatform != stdenv.hostPlatform || withEbpf; + broken = stdenv.buildPlatform != stdenv.hostPlatform || withEbpf; description = "Real-time performance monitoring tool"; homepage = "https://www.netdata.cloud/"; changelog = "https://github.com/netdata/netdata/releases/tag/v${version}"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 2b931075d156..e662a84d170d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9664,7 +9664,6 @@ with pkgs; nerdctl = callPackage ../applications/networking/cluster/nerdctl { }; netdata = callPackage ../tools/system/netdata { - inherit (darwin.apple_sdk.frameworks) CoreFoundation IOKit; protobuf = protobuf_21; }; netdataCloud = netdata.override { From f8726f98ae2d06b8b95705f447e30ce6d4819acd Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 12 Sep 2024 20:09:46 -0500 Subject: [PATCH 4/4] netdata: 1.47.0 -> 1.47.1 --- pkgs/tools/system/netdata/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/system/netdata/default.nix b/pkgs/tools/system/netdata/default.nix index 9db4e7756858..c7c7554914c7 100644 --- a/pkgs/tools/system/netdata/default.nix +++ b/pkgs/tools/system/netdata/default.nix @@ -53,7 +53,7 @@ let stdenv' = if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv; in stdenv'.mkDerivation (finalAttrs: { - version = "1.47.0"; + version = "1.47.1"; pname = "netdata"; src = fetchFromGitHub { @@ -62,10 +62,10 @@ stdenv'.mkDerivation (finalAttrs: { rev = "v${finalAttrs.version}"; hash = if withCloudUi then - "sha256-eMapy4HQaEblDfZt2uVSfBWRlkstX7TxZDBgSv5bW/I=" + "sha256-/iXmIjWpZ0s/LELZM7rYYQ9cjLNdfdisyOvDyLddSY4=" # we delete the v2 GUI after fetching else - "sha256-Gx7u3Owh/fVAnSw91xfdcmyx4m+bvQAvDaUxzXQ36/0="; + "sha256-pAqxxsWYgqbmF6wFBfTCYYc3x/Ufyz2Xs4bwB1ToHjo="; fetchSubmodules = true; # Remove v2 dashboard distributed under NCUL1. Make sure an empty