about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorJosef Kemetmüller <josef.kemetmueller@gmail.com>2020-09-21 07:59:52 +0200
committerJosef Kemetmüller <josef.kemetmueller@gmail.com>2020-09-21 08:43:43 +0200
commit0996ac6b0ea3fb8530cfe59c24a1af4baeb553b4 (patch)
treeb13877b821b210e7651fd0ae7004c44de3567144 /pkgs
parent799f149bbff72426c5cf47f363f712801a1ae108 (diff)
nvtop: Make independent of Nvidia driver version
For packages relying on Nvidia drivers we don't want to hard-code the
location of a particular driver version in the RPATH. Otherwise the
software might fail with errors such as:

> Impossible to initialize nvidia nvml : Driver/library version mismatch

To fix this the usual pattern in nixpkgs is to add `/run/opengl-driver/lib`
to the RPATH of these binaries.
This is the global location where Nvidia libraries are available on
NixOS and so this makes sure that the nvtop binary can be run with all
versions of the driver.

At build time however these libraries are not available at that
particular location. For precisely this use case, Nvidia ships stub
versions of the driver libraries with the cudatoolkit. So we just need
to point CMake to that directory.

Fixes: #98328
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/tools/system/nvtop/default.nix16
-rw-r--r--pkgs/top-level/all-packages.nix4
2 files changed, 11 insertions, 9 deletions
diff --git a/pkgs/tools/system/nvtop/default.nix b/pkgs/tools/system/nvtop/default.nix
index cd9ec7c7082d2..59636fb5dc809 100644
--- a/pkgs/tools/system/nvtop/default.nix
+++ b/pkgs/tools/system/nvtop/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, fetchFromGitHub, cmake, nvidia_x11, cudatoolkit, ncurses }:
+{ stdenv, fetchFromGitHub, cmake, cudatoolkit, ncurses, addOpenGLRunpath }:
 
 stdenv.mkDerivation rec {
   pname = "nvtop";
@@ -6,22 +6,26 @@ stdenv.mkDerivation rec {
 
   src = fetchFromGitHub {
     owner = "Syllo";
-    repo  = "nvtop";
+    repo = "nvtop";
     rev = version;
     sha256 = "1b6yz54xddip1r0k8cbqg41dpyhds18fj29bj3yf40xvysklb0f4";
   };
 
   cmakeFlags = [
     "-DNVML_INCLUDE_DIRS=${cudatoolkit}/include"
-    "-DNVML_LIBRARIES=${nvidia_x11}/lib/libnvidia-ml.so"
+    "-DNVML_LIBRARIES=${cudatoolkit}/targets/x86_64-linux/lib/stubs/libnvidia-ml.so"
     "-DCMAKE_BUILD_TYPE=Release"
   ];
 
-  nativeBuildInputs = [ cmake ];
-  buildInputs = [ ncurses nvidia_x11 cudatoolkit ];
+  nativeBuildInputs = [ cmake addOpenGLRunpath ];
+  buildInputs = [ ncurses cudatoolkit ];
+
+  postFixup = ''
+    addOpenGLRunpath $out/bin/nvtop
+  '';
 
   meta = with stdenv.lib; {
-    description = "A (h)top like like task monitor for NVIDIA GPUs";
+    description = "A (h)top like task monitor for NVIDIA GPUs";
     homepage = "https://github.com/Syllo/nvtop";
     license = licenses.gpl3;
     platforms = platforms.linux;
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index f2a608f4dff90..b4b437ab91229 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -14607,9 +14607,7 @@ in
 
   nvidia-optical-flow-sdk = callPackage ../development/libraries/nvidia-optical-flow-sdk { };
 
-  nvtop = callPackage ../tools/system/nvtop {
-    nvidia_x11 = linuxPackages.nvidia_x11.override { libsOnly = true; };
-  };
+  nvtop = callPackage ../tools/system/nvtop { };
 
   ocl-icd = callPackage ../development/libraries/ocl-icd { };