From 23c81659b5de67f4cf032e31c024a8b1a283fc45 Mon Sep 17 00:00:00 2001 From: Bernardo Meurer Date: Tue, 17 Aug 2021 17:50:44 -0700 Subject: [PATCH] htop: optionally enable sensors and systemd support on Linux --- pkgs/tools/system/htop/default.nix | 31 ++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/pkgs/tools/system/htop/default.nix b/pkgs/tools/system/htop/default.nix index 25a397bc987c..9c254ab33d81 100644 --- a/pkgs/tools/system/htop/default.nix +++ b/pkgs/tools/system/htop/default.nix @@ -1,7 +1,14 @@ { lib, fetchFromGitHub, stdenv, autoreconfHook -, ncurses, IOKit +, ncurses +, IOKit +, sensorsSupport ? stdenv.isLinux, lm_sensors +, systemdSupport ? stdenv.isLinux, systemd }: +with lib; + +assert systemdSupport -> stdenv.isLinux; + stdenv.mkDerivation rec { pname = "htop"; version = "3.0.5"; @@ -15,10 +22,26 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ autoreconfHook ]; - buildInputs = [ ncurses - ] ++ lib.optionals stdenv.isDarwin [ IOKit ]; + buildInputs = [ ncurses ] + ++ optional stdenv.isDarwin IOKit + ++ optional sensorsSupport lm_sensors + ++ optional systemdSupport systemd + ; - meta = with lib; { + configureFlags = [ "--enable-unicode" ] + ++ optional sensorsSupport "--with-sensors" + ; + + postFixup = + let + optionalPatch = pred: so: optionalString pred "patchelf --add-needed ${so} $out/bin/htop"; + in + '' + ${optionalPatch sensorsSupport "${lm_sensors}/lib/libsensors.so"} + ${optionalPatch systemdSupport "${systemd}/lib/libsystemd.so"} + ''; + + meta = { description = "An interactive process viewer for Linux"; homepage = "https://htop.dev"; license = licenses.gpl2Only;