Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1nvidia_x11: sha256: 2 3{ stdenv, lib, fetchFromGitHub, fetchpatch, pkg-config, m4, jansson, gtk2, dbus, gtk3 4, libXv, libXrandr, libXext, libXxf86vm, libvdpau 5, librsvg, wrapGAppsHook 6, withGtk2 ? false, withGtk3 ? true 7}: 8 9let 10 src = fetchFromGitHub { 11 owner = "NVIDIA"; 12 repo = "nvidia-settings"; 13 rev = nvidia_x11.settingsVersion; 14 inherit sha256; 15 }; 16 17 libXNVCtrl = stdenv.mkDerivation { 18 pname = "libXNVCtrl"; 19 version = nvidia_x11.settingsVersion; 20 inherit src; 21 22 buildInputs = [ libXrandr libXext ]; 23 24 preBuild = '' 25 cd src/libXNVCtrl 26 ''; 27 28 makeFlags = [ 29 "OUTPUTDIR=." # src/libXNVCtrl 30 ]; 31 32 installPhase = '' 33 mkdir -p $out/lib 34 mkdir -p $out/include/NVCtrl 35 36 cp libXNVCtrl.a $out/lib 37 cp NVCtrl.h $out/include/NVCtrl 38 cp NVCtrlLib.h $out/include/NVCtrl 39 ''; 40 }; 41 42in 43 44stdenv.mkDerivation { 45 pname = "nvidia-settings"; 46 version = nvidia_x11.settingsVersion; 47 48 inherit src; 49 50 patches = lib.optional (lib.versionOlder nvidia_x11.settingsVersion "440") 51 (fetchpatch { 52 # fixes "multiple definition of `VDPAUDeviceFunctions'" linking errors 53 url = "https://github.com/NVIDIA/nvidia-settings/commit/a7c1f5fce6303a643fadff7d85d59934bd0cf6b6.patch"; 54 hash = "sha256-ZwF3dRTYt/hO8ELg9weoz1U/XcU93qiJL2d1aq1Jlak="; 55 }); 56 57 postPatch = lib.optionalString nvidia_x11.useProfiles '' 58 sed -i 's,/usr/share/nvidia/,${nvidia_x11.bin}/share/nvidia/,g' src/gtk+-2.x/ctkappprofile.c 59 ''; 60 61 enableParallelBuilding = true; 62 makeFlags = [ "NV_USE_BUNDLED_LIBJANSSON=0" ]; 63 64 preBuild = '' 65 if [ -e src/libXNVCtrl/libXNVCtrl.a ]; then 66 ( cd src/libXNVCtrl 67 make $makeFlags 68 ) 69 fi 70 ''; 71 72 nativeBuildInputs = [ pkg-config m4 ]; 73 74 buildInputs = [ jansson libXv libXrandr libXext libXxf86vm libvdpau nvidia_x11 gtk2 dbus ] 75 ++ lib.optionals withGtk3 [ gtk3 librsvg wrapGAppsHook ]; 76 77 installFlags = [ "PREFIX=$(out)" ]; 78 79 postInstall = '' 80 ${lib.optionalString (!withGtk2) '' 81 rm -f $out/lib/libnvidia-gtk2.so.* 82 ''} 83 ${lib.optionalString (!withGtk3) '' 84 rm -f $out/lib/libnvidia-gtk3.so.* 85 ''} 86 87 # Install the desktop file and icon. 88 # The template has substitution variables intended to be replaced resulting 89 # in absolute paths. Because absolute paths break after the desktop file is 90 # copied by a desktop environment, make Exec and Icon be just a name. 91 sed -i doc/nvidia-settings.desktop \ 92 -e "s|^Exec=.*$|Exec=nvidia-settings|" \ 93 -e "s|^Icon=.*$|Icon=nvidia-settings|" \ 94 -e "s|__NVIDIA_SETTINGS_DESKTOP_CATEGORIES__|Settings|g" 95 install doc/nvidia-settings.desktop -D -t $out/share/applications/ 96 install doc/nvidia-settings.png -D -t $out/share/icons/hicolor/128x128/apps/ 97 ''; 98 99 binaryName = if withGtk3 then ".nvidia-settings-wrapped" else "nvidia-settings"; 100 postFixup = '' 101 patchelf --set-rpath "$(patchelf --print-rpath $out/bin/$binaryName):$out/lib:${libXv}/lib" \ 102 $out/bin/$binaryName 103 ''; 104 105 passthru = { 106 inherit libXNVCtrl; 107 }; 108 109 meta = with lib; { 110 homepage = "https://www.nvidia.com/object/unix.html"; 111 description = "Settings application for NVIDIA graphics cards"; 112 license = licenses.unfreeRedistributable; 113 platforms = nvidia_x11.meta.platforms; 114 maintainers = with maintainers; [ abbradar ]; 115 }; 116}