Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 87 lines 2.3 kB view raw
1{ 2 lib, 3 fetchFromGitHub, 4 stdenv, 5 autoreconfHook, 6 pkg-config, 7 ncurses, 8 libcap, 9 libnl, 10 sensorsSupport ? stdenv.hostPlatform.isLinux, 11 lm_sensors, 12 systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, 13 systemd, 14}: 15 16assert systemdSupport -> stdenv.hostPlatform.isLinux; 17 18stdenv.mkDerivation rec { 19 pname = "htop"; 20 version = "3.4.1"; 21 22 src = fetchFromGitHub { 23 owner = "htop-dev"; 24 repo = "htop"; 25 rev = version; 26 hash = "sha256-fVqQwXbJus2IVE1Bzf3yJJpKK4qcZN/SCTX1XYkiHhU="; 27 }; 28 29 # upstream removed pkg-config support and uses dlopen now 30 postPatch = 31 let 32 libnlPath = lib.getLib libnl; 33 in 34 lib.optionalString stdenv.hostPlatform.isLinux '' 35 substituteInPlace configure.ac \ 36 --replace-fail /usr/include/libnl3 ${lib.getDev libnl}/include/libnl3 37 substituteInPlace linux/LibNl.c \ 38 --replace-fail libnl-3.so ${libnlPath}/lib/libnl-3.so \ 39 --replace-fail libnl-genl-3.so ${libnlPath}/lib/libnl-genl-3.so 40 ''; 41 42 nativeBuildInputs = [ autoreconfHook ] ++ lib.optional stdenv.hostPlatform.isLinux pkg-config; 43 44 buildInputs = [ 45 ncurses 46 ] 47 ++ lib.optionals stdenv.hostPlatform.isLinux [ 48 libcap 49 libnl 50 ] 51 ++ lib.optional sensorsSupport lm_sensors 52 ++ lib.optional systemdSupport systemd; 53 54 configureFlags = [ 55 "--enable-unicode" 56 "--sysconfdir=/etc" 57 ] 58 ++ lib.optionals stdenv.hostPlatform.isLinux [ 59 "--enable-affinity" 60 "--enable-capabilities" 61 "--enable-delayacct" 62 ] 63 ++ lib.optional sensorsSupport "--enable-sensors"; 64 65 postFixup = 66 let 67 optionalPatch = pred: so: lib.optionalString pred "patchelf --add-needed ${so} $out/bin/htop"; 68 in 69 lib.optionalString (!stdenv.hostPlatform.isStatic) '' 70 ${optionalPatch sensorsSupport "${lib.getLib lm_sensors}/lib/libsensors.so"} 71 ${optionalPatch systemdSupport "${systemd}/lib/libsystemd.so"} 72 ''; 73 74 meta = { 75 description = "Interactive process viewer"; 76 homepage = "https://htop.dev"; 77 license = lib.licenses.gpl2Only; 78 platforms = lib.platforms.all; 79 maintainers = with lib.maintainers; [ 80 rob 81 relrod 82 SuperSandro2000 83 ]; 84 changelog = "https://github.com/htop-dev/htop/blob/${version}/ChangeLog"; 85 mainProgram = "htop"; 86 }; 87}