about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/system/htop/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/system/htop/default.nix')
-rw-r--r--nixpkgs/pkgs/tools/system/htop/default.nix31
1 files changed, 27 insertions, 4 deletions
diff --git a/nixpkgs/pkgs/tools/system/htop/default.nix b/nixpkgs/pkgs/tools/system/htop/default.nix
index 25a397bc987c..9c254ab33d81 100644
--- a/nixpkgs/pkgs/tools/system/htop/default.nix
+++ b/nixpkgs/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
+  ;
+
+  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 = with lib; {
+  meta = {
     description = "An interactive process viewer for Linux";
     homepage = "https://htop.dev";
     license = licenses.gpl2Only;