about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/nvidia-x11/settings.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/os-specific/linux/nvidia-x11/settings.nix')
-rw-r--r--pkgs/os-specific/linux/nvidia-x11/settings.nix52
1 files changed, 35 insertions, 17 deletions
diff --git a/pkgs/os-specific/linux/nvidia-x11/settings.nix b/pkgs/os-specific/linux/nvidia-x11/settings.nix
index b11dc06c85ebf..a26acd144125c 100644
--- a/pkgs/os-specific/linux/nvidia-x11/settings.nix
+++ b/pkgs/os-specific/linux/nvidia-x11/settings.nix
@@ -16,7 +16,7 @@ nvidia_x11: sha256:
 , libXxf86vm
 , libvdpau
 , librsvg
-, wrapGAppsHook
+, wrapGAppsHook3
 , addOpenGLRunpath
 , withGtk2 ? false
 , withGtk3 ? true
@@ -30,6 +30,12 @@ let
     inherit sha256;
   };
 
+  meta = with lib; {
+    homepage = "https://www.nvidia.com/object/unix.html";
+    platforms = nvidia_x11.meta.platforms;
+    maintainers = with maintainers; [ abbradar aidalgol ];
+  };
+
   libXNVCtrl = stdenv.mkDerivation {
     pname = "libXNVCtrl";
     version = nvidia_x11.settingsVersion;
@@ -43,6 +49,14 @@ let
 
     makeFlags = [
       "OUTPUTDIR=." # src/libXNVCtrl
+      "libXNVCtrl.a"
+      "libXNVCtrl.so"
+    ];
+
+    patches = [
+      # Patch the Makefile to also produce a shared library.
+      (if lib.versionOlder nvidia_x11.settingsVersion "400" then ./libxnvctrl-build-shared-3xx.patch
+      else ./libxnvctrl-build-shared.patch)
     ];
 
     installPhase = ''
@@ -52,7 +66,14 @@ let
       cp libXNVCtrl.a $out/lib
       cp NVCtrl.h     $out/include/NVCtrl
       cp NVCtrlLib.h  $out/include/NVCtrl
+      cp -P libXNVCtrl.so* $out/lib
     '';
+
+    meta = meta // {
+      description = "NVIDIA NV-CONTROL X extension";
+      # https://github.com/NVIDIA/nvidia-settings/commit/edcf9edad9f52f9b10e63d4480bbe88b22dde884
+      license = lib.licenses.mit;
+    };
   };
 
 in
@@ -93,21 +114,20 @@ stdenv.mkDerivation {
     fi
   '';
 
-  nativeBuildInputs = [ pkg-config m4 addOpenGLRunpath ];
+  nativeBuildInputs = [ pkg-config m4 addOpenGLRunpath ]
+    ++ lib.optionals withGtk3 [ wrapGAppsHook3 ];
 
-  buildInputs = [ jansson libXv libXrandr libXext libXxf86vm libvdpau nvidia_x11 gtk2 dbus ]
-    ++ lib.optionals withGtk3 [ gtk3 librsvg wrapGAppsHook ];
+  buildInputs = [ jansson libXv libXrandr libXext libXxf86vm libvdpau nvidia_x11 dbus ]
+    ++ lib.optionals (withGtk2 || lib.versionOlder nvidia_x11.settingsVersion "525.53") [ gtk2 ]
+    ++ lib.optionals withGtk3 [ gtk3 librsvg ];
 
   installFlags = [ "PREFIX=$(out)" ];
 
-  postInstall = ''
-    ${lib.optionalString (!withGtk2) ''
-      rm -f $out/lib/libnvidia-gtk2.so.*
-    ''}
-    ${lib.optionalString (!withGtk3) ''
-      rm -f $out/lib/libnvidia-gtk3.so.*
-    ''}
-
+  postInstall = lib.optionalString (!withGtk2) ''
+    rm -f $out/lib/libnvidia-gtk2.so.*
+  '' + lib.optionalString (!withGtk3) ''
+    rm -f $out/lib/libnvidia-gtk3.so.*
+  '' + ''
     # Install the desktop file and icon.
     # The template has substitution variables intended to be replaced resulting
     # in absolute paths. Because absolute paths break after the desktop file is
@@ -132,12 +152,10 @@ stdenv.mkDerivation {
     inherit libXNVCtrl;
   };
 
-  meta = with lib; {
-    homepage = "https://www.nvidia.com/object/unix.html";
+  meta = meta // {
     description = "Settings application for NVIDIA graphics cards";
-    license = licenses.unfreeRedistributable;
-    platforms = nvidia_x11.meta.platforms;
+    # nvml.h is licensed as part of the cuda developer license.
+    license = lib.licenses.unfreeRedistributable;
     mainProgram = "nvidia-settings";
-    maintainers = with maintainers; [ abbradar ];
   };
 }