nixpkgs/pkgs/tools/system/nvtop/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.9 KiB
Nix
Raw Normal View History

{ lib
, stdenv
, fetchFromGitHub
, cmake
, cudatoolkit
, libdrm
, ncurses
, addOpenGLRunpath
, amd ? true
, nvidia ? true
}:
2018-07-21 17:04:04 +00:00
let
pname-suffix = if amd && nvidia then "" else if amd then "-amd" else "-nvidia";
nvidia-postFixup = "addOpenGLRunpath $out/bin/nvtop";
libPath = lib.makeLibraryPath [ libdrm ncurses ];
amd-postFixup = ''
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${libPath}" \
$out/bin/nvtop
'';
in
2018-07-21 17:04:04 +00:00
stdenv.mkDerivation rec {
pname = "nvtop" + pname-suffix;
version = "2.0.1";
2018-07-21 17:04:04 +00:00
src = fetchFromGitHub {
owner = "Syllo";
repo = "nvtop";
2018-07-21 17:04:04 +00:00
rev = version;
sha256 = "sha256-4Alc5pBXb38PUhTRhdKZMiW+P3daDB0q3jiVL8qqEe4=";
2018-07-21 17:04:04 +00:00
};
cmakeFlags = with lib; [
2018-07-21 17:04:04 +00:00
"-DCMAKE_BUILD_TYPE=Release"
] ++ optional nvidia "-DNVML_INCLUDE_DIRS=${cudatoolkit}/include"
++ optional nvidia "-DNVML_LIBRARIES=${cudatoolkit}/targets/x86_64-linux/lib/stubs/libnvidia-ml.so"
++ optional (!amd) "-DAMDGPU_SUPPORT=OFF"
++ optional (!nvidia) "-DNVIDIA_SUPPORT=OFF"
++ optional amd "-DLibdrm_INCLUDE_DIRS=${libdrm}/lib/stubs/libdrm.so.2"
;
nativeBuildInputs = [ cmake] ++ lib.optional nvidia addOpenGLRunpath;
buildInputs = with lib; [ ncurses ]
++ optional nvidia cudatoolkit
++ optional amd libdrm
;
# ordering of fixups is important
postFixup = (lib.optionalString amd amd-postFixup) + (lib.optionalString nvidia nvidia-postFixup);
2018-07-21 17:04:04 +00:00
meta = with lib; {
description = "A (h)top like task monitor for AMD and NVIDIA GPUs";
longDescription = ''
Nvtop stands for Neat Videocard TOP, a (h)top like task monitor for AMD and NVIDIA GPUs. It can handle multiple GPUs and print information about them in a htop familiar way.
'';
homepage = "https://github.com/Syllo/nvtop";
2018-07-21 17:04:04 +00:00
license = licenses.gpl3;
platforms = platforms.linux;
maintainers = with maintainers; [ willibutz gbtb ];
2018-07-21 17:04:04 +00:00
};
}