htop: optionally enable sensors and systemd support on Linux

This commit is contained in:
Bernardo Meurer 2021-08-17 17:50:44 -07:00
parent 0944088287
commit 23c81659b5
No known key found for this signature in database
GPG Key ID: F4C0D53B8D14C246

View File

@ -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;