New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/netdata: support adding extra packages to service PATH #33439
nixos/netdata: support adding extra packages to service PATH #33439
Conversation
Fixes NixOS#33366, although a fair number of python plugins seem to fail for subsequent reasons (as triaged by viewing netdata's error.log).
I would still prefer patching the plugin loader – that way, you can run the file manually. If closure size is an issue, there are split outputs. |
@jtojnar I'm not convinced that will fix the problem. Can you offer any clarification? Also, that's not as flexible as my approach, which allows for either Python 2.x or Python 3.x. |
@kevlar1818 If you change shebang to The updated patch would look like this (not tested): --- a/pkgs/tools/system/netdata/default.nix
+++ b/pkgs/tools/system/netdata/default.nix
@@ -1,6 +1,10 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, zlib, pkgconfig, libuuid }:
+{ stdenv, fetchFromGitHub, autoreconfHook, zlib, pkgconfig, libuuid, python3 }:
-stdenv.mkDerivation rec{
+
+let
+ # https://github.com/firehol/netdata/wiki/Installation#1-prepare-your-system
+ python = with python3.pkgs; python.withPackages [ pyyaml dnspython pymongo pymysql psycopg2 ];
+in stdenv.mkDerivation rec{
version = "1.9.0";
name = "netdata-${version}";
@@ -12,10 +16,13 @@
};
nativeBuildInputs = [ autoreconfHook pkgconfig ];
- buildInputs = [ zlib libuuid ];
+ buildInputs = [ zlib libuuid python ];
# Allow UI to load when running as non-root
- patches = [ ./web_access.patch ];
+ patches = [
+ ./web_access.patch
+ ./python-plugins.patch
+ ];
# Build will fail trying to create /var/{cache,lib,log}/netdata without this
postPatch = ''
--- /dev/null
+++ b/pkgs/tools/system/netdata/python-plugins.patch
@@ -0,0 +1,10 @@
+--- a/plugins.d/python.d.plugin
++++ b/plugins.d/python.d.plugin
+@@ -1,6 +1,4 @@
+-#!/usr/bin/env bash
+-'''':; exec "$(command -v python || command -v python3 || command -v python2 ||
+-echo "ERROR python IS NOT AVAILABLE IN THIS SYSTEM")" "$0" "$@" # '''
++#!/usr/bin/env python3
+
+ # -*- coding: utf-8 -*-
+ # Description: |
@jtojnar How do you envision an end-user modifying the extra plugin packages? I think it should be as frictionless as possible for someone to choose between a basic netdata install and a customized and/or fully-loaded netdata install. |
If we want to allow installing plugin-less netdata, we could move the relevant plugins into split outputs. Or we could add an |
@jtojnar What about built-in plugins that use other programs, such as lm_sensors or IFPS? Do we install them too? I don't think it's sustainable to install all the programs for all the plugins. |
Maybe something like this? --- a/pkgs/tools/system/netdata/default.nix
+++ b/pkgs/tools/system/netdata/default.nix
@@ -1,6 +1,16 @@
-{ stdenv, fetchFromGitHub, autoreconfHook, zlib, pkgconfig, libuuid }:
+{ stdenv, fetchFromGitHub, autoreconfHook, zlib, pkgconfig, libuuid, makeWrapper
+, withPython ? false, python3, withNode ? false, nodejs, withLmSensors ? false, lm_sensors }:
-stdenv.mkDerivation rec{
+let
+ inherit (stdenv.lib) optional optionalString;
+ # https://github.com/firehol/netdata/wiki/Installation#1-prepare-your-system
+ python = python3.withPackages (p: with p; [ pyyaml dnspython pymongo pymysql psycopg2 ]);
+ binDependencies =
+ optional withPython python
+ ++ optional withNode nodejs;
+ libDependencies =
+ optional withLmSensors lm_sensors;
+in stdenv.mkDerivation rec{
version = "1.9.0";
name = "netdata-${version}";
@@ -11,11 +21,13 @@
sha256 = "1vy0jz5lxw63b830l9jgf1qqhp41gzapyhdr5k1gwg3zghvlg10w";
};
- nativeBuildInputs = [ autoreconfHook pkgconfig ];
+ nativeBuildInputs = [ autoreconfHook pkgconfig makeWrapper ];
buildInputs = [ zlib libuuid ];
# Allow UI to load when running as non-root
- patches = [ ./web_access.patch ];
+ patches = [
+ ./web_access.patch
+ ];
# Build will fail trying to create /var/{cache,lib,log}/netdata without this
postPatch = ''
@@ -30,8 +42,19 @@
# The upstream installer does prepare an empty file too
postInstall = ''
touch $out/etc/netdata/netdata.conf
+
'';
+ postFixup = ''
+ wrapProgram $out/bin/netdata \
+ --prefix PATH : "${stdenv.lib.makeBinPath binDependencies}" \
+ --prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath libDependencies}"
+ ''
+ # Remove unwanted plugins so that they cannot be accidentally enabled
+ + optionalString (!withPython) "rm -rf $out/libexec/netdata/python.d/*"
+ + optionalString (!withNode) "rm -rf $out/libexec/netdata/node.d/*"
+ + optionalString (!withLmSensors) "rm -f $out/libexec/netdata/python.d/sensors.chart.py";
+
meta = with stdenv.lib; {
description = "Real-time performance monitoring tool";
homepage = http://netdata.firehol.org; |
@jtojnar I guess what I'm getting at is that this pattern would have to be duplicated a hundred times or more to enable all the plugins in netdata. Because netdata prides itself on it's wealth of auto-detected plugins, I would argue for a simpler way to enable plugins (ideally, zero configuration). That is why I prefer my approach. If there's some middle ground to our two solutions, such as a more generic way to call |
The problem is autoconfiguration is just against Nix way of doing things. We sometimes compromise on this when it is too complicated to fix, but in this case, it is fairly simple, even though slightly verbose. |
What is the status of this pull request? |
I'm no longer working on this PR. |
Motivation for this change
Fixes #33366, although a fair number of python plugins seem to fail
for subsequent reasons (as triaged by viewing netdata's error.log).
cc @jtojnar @davidak @cransom
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)