mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-15 18:23:09 +00:00
42815b4a0c
Many packages have some kind of flag indicating whether or not to build with systemd support. Most of these default to `stdenv.isLinux`, but systemd does not build on (and is marked `broken` for) `isStatic`. Only a few packages have the needed `&& !isStatic` in the default value for their parameter. This commit moves the logic for the default value of these flags into `systemd.meta.{platforms,badPlatforms}` and evaluates those conditions using `lib.meta.availableOn`. This provides three benefits: 1. The default values are set correctly (i.e. including `&& isStatic`) 2. The default values are set consistently 3. The way is paved for any future non-Linux systemd platforms (FreeBSD is reported to have experimental systemd support)
50 lines
1.4 KiB
Nix
50 lines
1.4 KiB
Nix
{ lib, fetchFromGitHub, stdenv, autoreconfHook
|
|
, ncurses
|
|
, IOKit
|
|
, sensorsSupport ? stdenv.isLinux, lm_sensors
|
|
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
|
|
}:
|
|
|
|
assert systemdSupport -> stdenv.isLinux;
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "htop";
|
|
version = "3.2.1";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "htop-dev";
|
|
repo = pname;
|
|
rev = version;
|
|
sha256 = "sha256-MwtsvdPHcUdegsYj9NGyded5XJQxXri1IM1j4gef1Xk=";
|
|
};
|
|
|
|
nativeBuildInputs = [ autoreconfHook ];
|
|
|
|
buildInputs = [ ncurses ]
|
|
++ lib.optional stdenv.isDarwin IOKit
|
|
++ lib.optional sensorsSupport lm_sensors
|
|
++ lib.optional systemdSupport systemd
|
|
;
|
|
|
|
configureFlags = [ "--enable-unicode" "--sysconfdir=/etc" ]
|
|
++ lib.optional sensorsSupport "--with-sensors"
|
|
;
|
|
|
|
postFixup =
|
|
let
|
|
optionalPatch = pred: so: lib.optionalString pred "patchelf --add-needed ${so} $out/bin/htop";
|
|
in lib.optionalString (!stdenv.hostPlatform.isStatic) ''
|
|
${optionalPatch sensorsSupport "${lm_sensors}/lib/libsensors.so"}
|
|
${optionalPatch systemdSupport "${systemd}/lib/libsystemd.so"}
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "An interactive process viewer";
|
|
homepage = "https://htop.dev";
|
|
license = licenses.gpl2Only;
|
|
platforms = platforms.all;
|
|
maintainers = with maintainers; [ rob relrod SuperSandro2000 ];
|
|
changelog = "https://github.com/htop-dev/htop/blob/${version}/ChangeLog";
|
|
};
|
|
}
|