27 src = fetchFromGitHub {
29 repo = "nvidia-settings";
30 rev = nvidia_x11.settingsVersion;
35 homepage = "https://www.nvidia.com/object/unix.html";
36 platforms = nvidia_x11.meta.platforms;
37 maintainers = with maintainers; [ abbradar aidalgol ];
40 libXNVCtrl = stdenv.mkDerivation {
42 version = nvidia_x11.settingsVersion;
45 buildInputs = [ libXrandr libXext ];
52 "OUTPUTDIR=." # src/libXNVCtrl
58 # Patch the Makefile to also produce a shared library.
59 (if lib.versionOlder nvidia_x11.settingsVersion "400" then ./libxnvctrl-build-shared-3xx.patch
60 else ./libxnvctrl-build-shared.patch)
65 mkdir -p $out/include/NVCtrl
67 cp libXNVCtrl.a $out/lib
68 cp NVCtrl.h $out/include/NVCtrl
69 cp NVCtrlLib.h $out/include/NVCtrl
70 cp -P libXNVCtrl.so* $out/lib
74 description = "NVIDIA NV-CONTROL X extension";
75 # https://github.com/NVIDIA/nvidia-settings/commit/edcf9edad9f52f9b10e63d4480bbe88b22dde884
76 license = lib.licenses.mit;
83 pname = "nvidia-settings";
84 version = nvidia_x11.settingsVersion;
88 patches = lib.optional (lib.versionOlder nvidia_x11.settingsVersion "440")
90 # fixes "multiple definition of `VDPAUDeviceFunctions'" linking errors
91 url = "https://github.com/NVIDIA/nvidia-settings/commit/a7c1f5fce6303a643fadff7d85d59934bd0cf6b6.patch";
92 hash = "sha256-ZwF3dRTYt/hO8ELg9weoz1U/XcU93qiJL2d1aq1Jlak=";
95 ((lib.versionAtLeast nvidia_x11.settingsVersion "515.43.04")
96 && (lib.versionOlder nvidia_x11.settingsVersion "545.29"))
98 # fix wayland support for compositors that use wl_output version 4
99 url = "https://github.com/NVIDIA/nvidia-settings/pull/99/commits/2e0575197e2b3247deafd2a48f45afc038939a06.patch";
100 hash = "sha256-wKuO5CUTUuwYvsP46Pz+6fI0yxLNpZv8qlbL0TFkEFE=";
103 postPatch = lib.optionalString nvidia_x11.useProfiles ''
104 sed -i 's,/usr/share/nvidia/,${nvidia_x11.bin}/share/nvidia/,g' src/gtk+-2.x/ctkappprofile.c
107 enableParallelBuilding = true;
108 makeFlags = [ "NV_USE_BUNDLED_LIBJANSSON=0" ];
111 if [ -e src/libXNVCtrl/libXNVCtrl.a ]; then
118 nativeBuildInputs = [ pkg-config m4 addDriverRunpath ]
119 ++ lib.optionals withGtk3 [ wrapGAppsHook3 ];
121 buildInputs = [ jansson libXv libXrandr libXext libXxf86vm libvdpau nvidia_x11 dbus vulkan-headers ]
122 ++ lib.optionals (withGtk2 || lib.versionOlder nvidia_x11.settingsVersion "525.53") [ gtk2 ]
123 ++ lib.optionals withGtk3 [ gtk3 librsvg ];
125 installFlags = [ "PREFIX=$(out)" ];
127 postInstall = lib.optionalString (!withGtk2) ''
128 rm -f $out/lib/libnvidia-gtk2.so.*
129 '' + lib.optionalString (!withGtk3) ''
130 rm -f $out/lib/libnvidia-gtk3.so.*
132 # Install the desktop file and icon.
133 # The template has substitution variables intended to be replaced resulting
134 # in absolute paths. Because absolute paths break after the desktop file is
135 # copied by a desktop environment, make Exec and Icon be just a name.
136 sed -i doc/nvidia-settings.desktop \
137 -e "s|^Exec=.*$|Exec=nvidia-settings|" \
138 -e "s|^Icon=.*$|Icon=nvidia-settings|" \
139 -e "s|__NVIDIA_SETTINGS_DESKTOP_CATEGORIES__|Settings|g"
140 install doc/nvidia-settings.desktop -D -t $out/share/applications/
141 install doc/nvidia-settings.png -D -t $out/share/icons/hicolor/128x128/apps/
144 binaryName = if withGtk3 then ".nvidia-settings-wrapped" else "nvidia-settings";
146 patchelf --set-rpath "$(patchelf --print-rpath $out/bin/$binaryName):$out/lib:${libXv}/lib" \
149 addDriverRunpath $out/bin/$binaryName
157 description = "Settings application for NVIDIA graphics cards";
158 # nvml.h is licensed as part of the cuda developer license.
159 license = lib.licenses.unfreeRedistributable;
160 mainProgram = "nvidia-settings";