From fd9d8edc51258a59a9444f7cd32f6ec7b8a8f2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Wed, 24 Dec 2014 00:01:04 +0100 Subject: [PATCH] nvidia_x11: add 343 branch as the default (close #5070) It's just a plain copy of the 340 expressions (only hash and version changed). --- pkgs/os-specific/linux/nvidia-x11/builder.sh | 107 ++++++++++++++++++ pkgs/os-specific/linux/nvidia-x11/default.nix | 64 +++++++++++ pkgs/top-level/all-packages.nix | 3 +- 3 files changed, 172 insertions(+), 2 deletions(-) create mode 100755 pkgs/os-specific/linux/nvidia-x11/builder.sh create mode 100644 pkgs/os-specific/linux/nvidia-x11/default.nix diff --git a/pkgs/os-specific/linux/nvidia-x11/builder.sh b/pkgs/os-specific/linux/nvidia-x11/builder.sh new file mode 100755 index 00000000000..4291116f4ef --- /dev/null +++ b/pkgs/os-specific/linux/nvidia-x11/builder.sh @@ -0,0 +1,107 @@ +source $stdenv/setup + +dontPatchELF=1 # must keep libXv, $out in RPATH + + +unpackFile() { + skip=$(sed 's/^skip=//; t; d' $src) + tail -n +$skip $src | xz -d | tar xvf - + sourceRoot=. +} + + +buildPhase() { + if test -z "$libsOnly"; then + # Create the module. + echo "Building linux driver against kernel: $kernel"; + cd kernel + kernelVersion=$(cd $kernel/lib/modules && ls) + sysSrc=$(echo $kernel/lib/modules/$kernelVersion/source) + sysOut=$(echo $kernel/lib/modules/$kernelVersion/build) + unset src # used by the nv makefile + make SYSSRC=$sysSrc SYSOUT=$sysOut module + cd uvm + make SYSSRC=$sysSrc SYSOUT=$sysOut module + cd .. + cd .. + fi +} + + +installPhase() { + + if test -z "$libsOnly"; then + # Install the kernel module. + mkdir -p $out/lib/modules/$kernelVersion/misc + cp kernel/nvidia.ko $out/lib/modules/$kernelVersion/misc + cp kernel/uvm/nvidia-uvm.ko $out/lib/modules/$kernelVersion/misc + + # Install the X driver. + mkdir -p $out/lib/xorg/modules + cp -p libnvidia-wfb.* $out/lib/xorg/modules/ + mkdir -p $out/lib/xorg/modules/drivers + cp -p nvidia_drv.so $out/lib/xorg/modules/drivers + mkdir -p $out/lib/xorg/modules/extensions + cp -p libglx.so.* $out/lib/xorg/modules/extensions + + #patchelf --set-rpath $out/lib $out/lib/xorg/modules/extensions/libglx.so.*.* + + # Install the programs. + mkdir -p $out/bin + + for i in nvidia-settings nvidia-smi; do + cp $i $out/bin/$i + patchelf --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \ + --set-rpath $out/lib:$programPath:$glPath $out/bin/$i + done + + # Header files etc. + mkdir -p $out/include/nvidia + cp -p *.h $out/include/nvidia + + mkdir -p $out/share/man/man1 + cp -p *.1.gz $out/share/man/man1 + rm $out/share/man/man1/nvidia-xconfig.1.gz + + mkdir -p $out/share/applications + cp -p *.desktop $out/share/applications + + mkdir -p $out/share/pixmaps + cp -p nvidia-settings.png $out/share/pixmaps + + # Patch the `nvidia-settings.desktop' file. + substituteInPlace $out/share/applications/nvidia-settings.desktop \ + --replace '__UTILS_PATH__' $out/bin \ + --replace '__PIXMAP_PATH__' $out/share/pixmaps + + # Test a bit. + $out/bin/nvidia-settings --version + fi + + + # Install libGL and friends. + mkdir -p "$out/lib/vendors" + cp -p nvidia.icd $out/lib/vendors/ + + cp -prd *.so.* tls "$out/lib/" + rm "$out"/lib/lib{glx,nvidia-wfb}.so.* # handled separately + + for libname in `find "$out/lib/" -name '*.so.*'` + do + # I'm lazy to differentiate needed libs per-library, as the closure is the same. + # Unfortunately --shrink-rpath would strip too much. + patchelf --set-rpath "$out/lib:$allLibPath" "$libname" + + libname_short=`echo -n "$libname" | sed 's/so\..*/so/'` + ln -srnf "$libname" "$libname_short" + ln -srnf "$libname" "$libname_short.1" + done + + #patchelf --set-rpath $out/lib:$glPath $out/lib/libGL.so.*.* + #patchelf --set-rpath $out/lib:$glPath $out/lib/libvdpau_nvidia.so.*.* + #patchelf --set-rpath $cudaPath $out/lib/libcuda.so.*.* + #patchelf --set-rpath $openclPath $out/lib/libnvidia-opencl.so.*.* +} + + +genericBuild diff --git a/pkgs/os-specific/linux/nvidia-x11/default.nix b/pkgs/os-specific/linux/nvidia-x11/default.nix new file mode 100644 index 00000000000..59b17db7662 --- /dev/null +++ b/pkgs/os-specific/linux/nvidia-x11/default.nix @@ -0,0 +1,64 @@ +{ stdenv, fetchurl, kernel ? null, xlibs, zlib, perl +, gtk, atk, pango, glib, gdk_pixbuf +, # Whether to build the libraries only (i.e. not the kernel module or + # nvidia-settings). Used to support 32-bit binaries on 64-bit + # Linux. + libsOnly ? false +}: + +with stdenv.lib; + +assert (!libsOnly) -> kernel != null; + +let + + versionNumber = "343.36"; + /* This branch is needed for G8x, G9x, and GT2xx GPUs, and motherboard chipsets based on them. + Ongoing support for new Linux kernels and X servers, as well as fixes for critical bugs, + will be included in 340.* legacy releases through the end of 2019. + */ + inherit (stdenv.lib) makeLibraryPath; +in + +stdenv.mkDerivation { + name = "nvidia-x11-${versionNumber}${optionalString (!libsOnly) "-${kernel.version}"}"; + + builder = ./builder.sh; + + src = + if stdenv.system == "i686-linux" then + fetchurl { + url = "http://us.download.nvidia.com/XFree86/Linux-x86/${versionNumber}/NVIDIA-Linux-x86-${versionNumber}.run"; + sha256 = "17l23dp725883xcyy1n178pcl6lj27psrgbxymc356x2pngwkhcc"; + } + else if stdenv.system == "x86_64-linux" then + fetchurl { + url = "http://us.download.nvidia.com/XFree86/Linux-x86_64/${versionNumber}/NVIDIA-Linux-x86_64-${versionNumber}-no-compat32.run"; + sha256 = "0djvh9wmazrfvpgyiqrz81kjk2war20xyjjr2kncxyplzk28mw97"; + } + else throw "nvidia-x11 does not support platform ${stdenv.system}"; + + inherit versionNumber libsOnly; + + kernel = if libsOnly then null else kernel.dev; + + dontStrip = true; + + glPath = makeLibraryPath [xlibs.libXext xlibs.libX11 xlibs.libXrandr]; + cudaPath = makeLibraryPath [zlib stdenv.gcc.gcc]; + openclPath = makeLibraryPath [zlib]; + allLibPath = makeLibraryPath [xlibs.libXext xlibs.libX11 xlibs.libXrandr zlib stdenv.gcc.gcc]; + + programPath = optionalString (!libsOnly) (makeLibraryPath + [ gtk atk pango glib gdk_pixbuf xlibs.libXv ] ); + + buildInputs = [ perl ]; + + meta = with stdenv.lib.meta; { + homepage = http://www.nvidia.com/object/unix.html; + description = "X.org driver and kernel module for NVIDIA graphics cards"; + license = licenses.unfreeRedistributable; + platforms = platforms.linux; + maintainers = [ maintainers.vcunat ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8f807606db5..663fa14d076 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8363,11 +8363,10 @@ let nvidiabl = callPackage ../os-specific/linux/nvidiabl { }; - nvidia_x11 = self.nvidia_x11_legacy340; - nvidia_x11_legacy173 = callPackage ../os-specific/linux/nvidia-x11/legacy173.nix { }; nvidia_x11_legacy304 = callPackage ../os-specific/linux/nvidia-x11/legacy304.nix { }; nvidia_x11_legacy340 = callPackage ../os-specific/linux/nvidia-x11/legacy340.nix { }; + nvidia_x11 = callPackage ../os-specific/linux/nvidia-x11 { }; openafsClient = callPackage ../servers/openafs-client { };