-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
/
default.nix
80 lines (73 loc) · 2.29 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{ lib
, stdenv
, fetchFromGitHub
, cmake
, gtest
, cudatoolkit
, libdrm
, ncurses
, nvtop
, testers
, udev
, addOpenGLRunpath
, amd ? true
, nvidia ? true
}:
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 udev ];
amd-postFixup = ''
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${libPath}" \
$out/bin/nvtop
'';
in
stdenv.mkDerivation rec {
pname = "nvtop" + pname-suffix;
version = "3.0.1";
src = fetchFromGitHub {
owner = "Syllo";
repo = "nvtop";
rev = version;
hash = "sha256-vLvt2sankpQWAVZBPo3OePs4LDy7YfVnMkZLfN6ERAc=";
};
cmakeFlags = with lib; [
"-DCMAKE_BUILD_TYPE=Release"
"-DBUILD_TESTING=ON"
"-DUSE_LIBUDEV_OVER_LIBSYSTEMD=ON"
] ++ 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 gtest ] ++ lib.optional nvidia addOpenGLRunpath;
buildInputs = with lib; [ ncurses udev ]
++ optional nvidia cudatoolkit
++ optional amd libdrm
;
# ordering of fixups is important
postFixup = (lib.optionalString amd amd-postFixup) + (lib.optionalString nvidia nvidia-postFixup);
doCheck = true;
passthru = {
tests.version = testers.testVersion {
inherit version;
package = nvtop;
command = "nvtop --version";
};
};
meta = with lib; {
description = "A (h)top like task monitor for AMD, Intel and NVIDIA GPUs";
longDescription = ''
Nvtop stands for Neat Videocard TOP, a (h)top like task monitor for AMD, Intel and NVIDIA GPUs. It can handle multiple GPUs and print information about them in a htop familiar way.
'';
homepage = "https://github.com/Syllo/nvtop";
changelog = "https://github.com/Syllo/nvtop/releases/tag/${version}";
license = licenses.gpl3Only;
platforms = platforms.linux;
maintainers = with maintainers; [ willibutz gbtb anthonyroussel ];
mainProgram = "nvtop";
};
}