From 3d7450c9708e6b8102a5608b8405fd121f89de2c Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 13 Mar 2025 22:54:23 +0000 Subject: [PATCH 1/3] htop-vim: fix build by not depending in htop derivation Fix #389663. --- pkgs/tools/system/htop/htop-vim.nix | 70 ++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 6 deletions(-) diff --git a/pkgs/tools/system/htop/htop-vim.nix b/pkgs/tools/system/htop/htop-vim.nix index 28fafbe38829..55354d827537 100644 --- a/pkgs/tools/system/htop/htop-vim.nix +++ b/pkgs/tools/system/htop/htop-vim.nix @@ -1,10 +1,23 @@ { lib, - htop, fetchFromGitHub, + fetchpatch2, + stdenv, + autoreconfHook, + pkg-config, + ncurses, + darwin, + libcap, + libnl, + sensorsSupport ? stdenv.hostPlatform.isLinux, + lm_sensors, + systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, + systemd, }: -htop.overrideAttrs (oldAttrs: rec { +assert systemdSupport -> stdenv.hostPlatform.isLinux; + +stdenv.mkDerivation rec { pname = "htop-vim"; version = "unstable-2023-02-16"; @@ -15,11 +28,56 @@ htop.overrideAttrs (oldAttrs: rec { hash = "sha256-ZfdBAlnjoy8g6xwrR/i2+dGldMOfLlX6DRlNqB8pkGM="; }; + patches = [ + # See https://github.com/htop-dev/htop/pull/1412 + # Remove when updating to 3.4.0 + (fetchpatch2 { + name = "htop-resolve-configuration-path.patch"; + url = "https://github.com/htop-dev/htop/commit/0dac8e7d38ec3aeae901a987717b5177986197e4.patch"; + hash = "sha256-Er1d/yV1fioYfEmXNlLO5ayAyXkyy+IaGSx1KWXvlv0="; + }) + ]; + + nativeBuildInputs = [ autoreconfHook ] ++ lib.optional stdenv.hostPlatform.isLinux pkg-config; + + buildInputs = + [ ncurses ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.IOKit ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + libcap + libnl + ] + ++ lib.optional sensorsSupport lm_sensors + ++ lib.optional systemdSupport systemd; + + configureFlags = + [ + "--enable-unicode" + "--sysconfdir=/etc" + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + "--enable-affinity" + "--enable-capabilities" + "--enable-delayacct" + ] + ++ lib.optional sensorsSupport "--enable-sensors"; + + postFixup = + let + optionalPatch = pred: so: lib.optionalString pred "patchelf --add-needed ${so} $out/bin/htop"; + in + lib.optionalString (!stdenv.hostPlatform.isStatic) '' + ${optionalPatch sensorsSupport "${lib.getLib lm_sensors}/lib/libsensors.so"} + ${optionalPatch systemdSupport "${systemd}/lib/libsystemd.so"} + ''; + meta = with lib; { - inherit (oldAttrs.meta) platforms license; - description = "Interactive process viewer for Linux, with vim-style keybindings"; - homepage = "https://github.com/KoffeinFlummi/htop-vim"; + description = "Interactive process viewer"; + homepage = "https://htop.dev"; + license = licenses.gpl2Only; + platforms = platforms.all; maintainers = with maintainers; [ thiagokokada ]; + changelog = "https://github.com/htop-dev/htop/blob/${version}/ChangeLog"; mainProgram = "htop"; }; -}) +} From c1908c017c5616d684b23026f10906ffdf5cc2f9 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 13 Mar 2025 22:56:30 +0000 Subject: [PATCH 2/3] htop-vim: move to pkgs/by-name --- .../htop/htop-vim.nix => by-name/ht/htop-vim/package.nix} | 0 pkgs/top-level/all-packages.nix | 2 -- 2 files changed, 2 deletions(-) rename pkgs/{tools/system/htop/htop-vim.nix => by-name/ht/htop-vim/package.nix} (100%) diff --git a/pkgs/tools/system/htop/htop-vim.nix b/pkgs/by-name/ht/htop-vim/package.nix similarity index 100% rename from pkgs/tools/system/htop/htop-vim.nix rename to pkgs/by-name/ht/htop-vim/package.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 04b2f59bb27c..6d76db71fed2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11937,8 +11937,6 @@ with pkgs; inherit (darwin) IOKit; }; - htop-vim = callPackage ../tools/system/htop/htop-vim.nix { }; - humility = callPackage ../development/tools/rust/humility { inherit (darwin.apple_sdk.frameworks) AppKit; }; From cce88d6e21fcad708b31bb39ac30e2d40040ad1e Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 13 Mar 2025 22:59:19 +0000 Subject: [PATCH 3/3] htop-vim: fix meta --- pkgs/by-name/ht/htop-vim/package.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/ht/htop-vim/package.nix b/pkgs/by-name/ht/htop-vim/package.nix index 55354d827537..cc9d20600ad3 100644 --- a/pkgs/by-name/ht/htop-vim/package.nix +++ b/pkgs/by-name/ht/htop-vim/package.nix @@ -72,12 +72,11 @@ stdenv.mkDerivation rec { ''; meta = with lib; { - description = "Interactive process viewer"; - homepage = "https://htop.dev"; + description = "Interactive process viewer, with vim-style keybindings"; + homepage = "https://github.com/KoffeinFlummi/htop-vim"; license = licenses.gpl2Only; platforms = platforms.all; maintainers = with maintainers; [ thiagokokada ]; - changelog = "https://github.com/htop-dev/htop/blob/${version}/ChangeLog"; mainProgram = "htop"; }; }