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;