2022-04-21 13:26:11 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2022-09-12 04:42:28 +00:00
|
|
|
, fetchpatch
|
2022-04-21 13:26:11 +00:00
|
|
|
, cmake
|
2022-06-13 14:25:17 +00:00
|
|
|
, gtest
|
2022-04-21 13:26:11 +00:00
|
|
|
, cudatoolkit
|
|
|
|
, libdrm
|
|
|
|
, ncurses
|
|
|
|
, addOpenGLRunpath
|
|
|
|
, amd ? true
|
|
|
|
, nvidia ? true
|
|
|
|
}:
|
2018-07-21 17:04:04 +00:00
|
|
|
|
2022-04-21 13:26:11 +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 {
|
2022-04-21 13:26:11 +00:00
|
|
|
pname = "nvtop" + pname-suffix;
|
2022-09-12 04:42:28 +00:00
|
|
|
version = "2.0.3";
|
2018-07-21 17:04:04 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Syllo";
|
2020-09-21 05:59:52 +00:00
|
|
|
repo = "nvtop";
|
2018-07-21 17:04:04 +00:00
|
|
|
rev = version;
|
2022-09-12 04:42:28 +00:00
|
|
|
sha256 = "sha256-LhVgNU2OSM7fOUUQHYJhKhjE0fkFvYC3FIJFgu6T68Q=";
|
2018-07-21 17:04:04 +00:00
|
|
|
};
|
|
|
|
|
2022-09-12 04:42:28 +00:00
|
|
|
#this patch should be fine to remove with next version update
|
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/Syllo/nvtop/commit/663a69f1c9038eabdfc3155112fb9b8d662578aa.diff";
|
|
|
|
sha256 = "sha256-/EJlr5b+kZnHm9UxythYreJvO+Ma+1sUI3KLBQFCCmc=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2022-04-21 13:26:11 +00:00
|
|
|
cmakeFlags = with lib; [
|
2018-07-21 17:04:04 +00:00
|
|
|
"-DCMAKE_BUILD_TYPE=Release"
|
2022-06-13 14:25:17 +00:00
|
|
|
"-DBUILD_TESTING=ON"
|
2022-04-21 13:26:11 +00:00
|
|
|
] ++ 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"
|
|
|
|
;
|
2022-06-13 14:25:17 +00:00
|
|
|
nativeBuildInputs = [ cmake gtest ] ++ lib.optional nvidia addOpenGLRunpath;
|
2022-04-21 13:26:11 +00:00
|
|
|
buildInputs = with lib; [ ncurses ]
|
|
|
|
++ optional nvidia cudatoolkit
|
|
|
|
++ optional amd libdrm
|
|
|
|
;
|
2020-09-21 05:59:52 +00:00
|
|
|
|
2022-04-21 13:26:11 +00:00
|
|
|
# ordering of fixups is important
|
|
|
|
postFixup = (lib.optionalString amd amd-postFixup) + (lib.optionalString nvidia nvidia-postFixup);
|
2018-07-21 17:04:04 +00:00
|
|
|
|
2022-06-13 14:25:17 +00:00
|
|
|
doCheck = true;
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2022-04-21 13:26:11 +00:00
|
|
|
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.
|
2022-06-13 14:25:17 +00:00
|
|
|
'';
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://github.com/Syllo/nvtop";
|
2018-07-21 17:04:04 +00:00
|
|
|
license = licenses.gpl3;
|
|
|
|
platforms = platforms.linux;
|
2022-04-21 13:26:11 +00:00
|
|
|
maintainers = with maintainers; [ willibutz gbtb ];
|
2018-07-21 17:04:04 +00:00
|
|
|
};
|
|
|
|
}
|