diff --git a/nixos/modules/hardware/video/bumblebee.nix b/nixos/modules/hardware/video/bumblebee.nix index fbf3f20885b5..3967137fcf8b 100644 --- a/nixos/modules/hardware/video/bumblebee.nix +++ b/nixos/modules/hardware/video/bumblebee.nix @@ -77,7 +77,7 @@ in config = mkIf cfg.enable { boot.blacklistedKernelModules = [ "nvidia-drm" "nvidia" "nouveau" ]; boot.kernelModules = optional useBbswitch "bbswitch"; - boot.extraModulePackages = optional useBbswitch kernel.bbswitch ++ optional useNvidia kernel.nvidia_x11; + boot.extraModulePackages = optional useBbswitch kernel.bbswitch ++ optional useNvidia kernel.nvidia_x11.bin; environment.systemPackages = [ bumblebee primus ]; diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix index b604d645132d..cf723d53269b 100644 --- a/nixos/modules/hardware/video/nvidia.nix +++ b/nixos/modules/hardware/video/nvidia.nix @@ -27,6 +27,13 @@ let nvidia_x11 = nvidiaForKernel config.boot.kernelPackages; nvidia_libs32 = (nvidiaForKernel pkgs_i686.linuxPackages).override { libsOnly = true; kernel = null; }; + nvidiaPackage = nvidia: pkgs: + if !nvidia.useGLVND then nvidia + else pkgs.buildEnv { + name = "nvidia-libs"; + paths = [ pkgs.libglvnd nvidia.out ]; + }; + enabled = nvidia_x11 != null; in @@ -35,19 +42,19 @@ in config = mkIf enabled { services.xserver.drivers = singleton - { name = "nvidia"; modules = [ nvidia_x11 ]; libPath = [ nvidia_x11 ]; }; + { name = "nvidia"; modules = [ nvidia_x11.bin ]; libPath = [ nvidia_x11 ]; }; services.xserver.screenSection = '' Option "RandRRotation" "on" ''; - hardware.opengl.package = nvidia_x11; - hardware.opengl.package32 = nvidia_libs32; + hardware.opengl.package = nvidiaPackage nvidia_x11 pkgs; + hardware.opengl.package32 = nvidiaPackage nvidia_libs32 pkgs_i686; - environment.systemPackages = [ nvidia_x11 ]; + environment.systemPackages = [ nvidia_x11.bin nvidia_x11.settings nvidia_x11.persistenced ]; - boot.extraModulePackages = [ nvidia_x11 ]; + boot.extraModulePackages = [ nvidia_x11.bin ]; # nvidia-uvm is required by CUDA applications. boot.kernelModules = [ "nvidia-uvm" ]; diff --git a/pkgs/development/libraries/libglvnd/default.nix b/pkgs/development/libraries/libglvnd/default.nix new file mode 100644 index 000000000000..07d63c66b781 --- /dev/null +++ b/pkgs/development/libraries/libglvnd/default.nix @@ -0,0 +1,31 @@ +{stdenv, fetchFromGitHub, autoreconfHook, python2, pkgconfig, mesa_noglu, libX11, libXext, glproto }: + +# Git version is needed for EGL and GLES handling. + +stdenv.mkDerivation rec { + name = "libglvnd-2016-12-22"; + + src = fetchFromGitHub { + owner = "NVIDIA"; + repo = "libglvnd"; + rev = "dc16f8c337703ad141f83583a4004fcf42e07766"; + sha256 = "1dbwf1216np77xf1kx3ci3y7hfa1p4vgrrzg71gw36hqxf36vg5f"; + }; + + nativeBuildInputs = [ autoreconfHook pkgconfig python2 ]; + buildInputs = [ libX11 libXext glproto ]; + + NIX_CFLAGS_COMPILE = [ + "-UDEFAULT_EGL_VENDOR_CONFIG_DIRS" + "-DDEFAULT_EGL_VENDOR_CONFIG_DIRS=\"${mesa_noglu.driverLink}/share/glvnd/egl_vendor.d\"" + ]; + + outputs = [ "out" "dev" ]; + + meta = with stdenv.lib; { + description = "The GL Vendor-Neutral Dispatch library"; + homepage = "https://github.com/NVIDIA/libglvnd"; + license = licenses.bsd2; + platforms = platforms.linux; + }; +} diff --git a/pkgs/os-specific/linux/nvidia-x11/beta.nix b/pkgs/os-specific/linux/nvidia-x11/beta.nix deleted file mode 100644 index 6fd5fb6c0b63..000000000000 --- a/pkgs/os-specific/linux/nvidia-x11/beta.nix +++ /dev/null @@ -1,68 +0,0 @@ -{ stdenv, fetchurl, kernel ? null, xorg, zlib, perl -, gtk, atk, pango, glib, gdk_pixbuf, cairo, nukeReferences -, # 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 = "349.12"; - - # Policy: use the highest stable version as the default (on our master). - 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 = "0x9zfw66nxv98zpkdkymlyqzspksk850bhfmza7g7pba4yba085h"; - } - 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 = "19mfkigzffxsik3h4bsjsl481q410h804fz3rdc7chs86q4bg9h3"; - } - else throw "nvidia-x11 does not support platform ${stdenv.system}"; - - inherit versionNumber libsOnly; - - kernel = if libsOnly then null else kernel.dev; - - hardeningDisable = [ "pic" "format" ]; - - dontStrip = true; - - glPath = makeLibraryPath [xorg.libXext xorg.libX11 xorg.libXrandr]; - cudaPath = makeLibraryPath [zlib stdenv.cc.cc]; - openclPath = makeLibraryPath [zlib]; - allLibPath = makeLibraryPath [xorg.libXext xorg.libX11 xorg.libXrandr zlib stdenv.cc.cc]; - - gtkPath = optionalString (!libsOnly) (makeLibraryPath - [ gtk atk pango glib gdk_pixbuf cairo ] ); - programPath = makeLibraryPath [ xorg.libXv ]; - - buildInputs = [ perl nukeReferences ]; - - disallowedReferences = if libsOnly then [] else [ kernel.dev ]; - - 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/os-specific/linux/nvidia-x11/builder-legacy304.sh b/pkgs/os-specific/linux/nvidia-x11/builder-legacy304.sh deleted file mode 100755 index fe8267831410..000000000000 --- a/pkgs/os-specific/linux/nvidia-x11/builder-legacy304.sh +++ /dev/null @@ -1,104 +0,0 @@ -source $stdenv/setup - -dontPatchELF=1 # must keep libXv, $out in RPATH - - -unpackFile() { - sh $src -x -} - - -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 .. - fi -} - - -installPhase() { - - # Install libGL and friends. - mkdir -p $out/lib/vendors - - for f in \ - libcuda libGL libnvcuvid libnvidia-cfg libnvidia-compiler \ - libnvidia-glcore libnvidia-ml libnvidia-opencl \ - libnvidia-tls libOpenCL libnvidia-tls libvdpau_nvidia - do - cp -prd $f.* $out/lib/ - ln -snf $f.so.$versionNumber $out/lib/$f.so - ln -snf $f.so.$versionNumber $out/lib/$f.so.1 - done - - cp -p nvidia.icd $out/lib/vendors/ - cp -prd tls $out/lib/ - cp -prd libOpenCL.so.1.0.0 $out/lib/ - ln -snf libOpenCL.so.1.0.0 $out/lib/libOpenCL.so - ln -snf libOpenCL.so.1.0.0 $out/lib/libOpenCL.so.1 - - 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.*.* - - 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 - - # 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 - - ln -snf libnvidia-wfb.so.$versionNumber $out/lib/xorg/modules/libnvidia-wfb.so.1 - ln -snf libglx.so.$versionNumber $out/lib/xorg/modules/extensions/libglx.so - - 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-xconfig; do - cp $i $out/bin/$i - patchelf --interpreter "$(cat $NIX_CC/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 - - 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 - - # Move VDPAU libraries to their place - mkdir "$out"/lib/vdpau - mv "$out"/lib/libvdpau* "$out"/lib/vdpau - fi -} - - -genericBuild diff --git a/pkgs/os-specific/linux/nvidia-x11/builder-legacy340.sh b/pkgs/os-specific/linux/nvidia-x11/builder-legacy340.sh deleted file mode 100755 index 899f12daf6b5..000000000000 --- a/pkgs/os-specific/linux/nvidia-x11/builder-legacy340.sh +++ /dev/null @@ -1,120 +0,0 @@ -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_CC/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/'` - - # nvidia's EGL stack seems to expect libGLESv2.so.2 to be available - if [ $(basename "$libname_short") == "libGLESv2.so" ]; then - ln -srnf "$libname" "$libname_short.2" - fi - - 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.*.* - - # We distribute these separately in `libvdpau` - rm "$out"/lib/libvdpau{.*,_trace.*} - - # Move VDPAU libraries to their place - mkdir "$out"/lib/vdpau - mv "$out"/lib/libvdpau* "$out"/lib/vdpau -} - - -genericBuild diff --git a/pkgs/os-specific/linux/nvidia-x11/builder.sh b/pkgs/os-specific/linux/nvidia-x11/builder.sh index b739fde15f74..98858c4c9851 100755 --- a/pkgs/os-specific/linux/nvidia-x11/builder.sh +++ b/pkgs/os-specific/linux/nvidia-x11/builder.sh @@ -1,17 +1,19 @@ source $stdenv/setup -dontPatchELF=1 # must keep libXv, $out in RPATH - - -unpackFile() { +unpackManually() { skip=$(sed 's/^skip=//; t; d' $src) tail -n +$skip $src | xz -d | tar xvf - sourceRoot=. } +unpackFile() { + sh $src -x || unpackManually +} + + buildPhase() { - if test -z "$libsOnly"; then + if [ -n "$bin" ]; then # Create the module. echo "Building linux driver against kernel: $kernel"; cd kernel @@ -25,45 +27,55 @@ buildPhase() { fi } - + installPhase() { # Install libGL and friends. - mkdir -p "$out/etc/OpenCL/vendors" - cp -p nvidia.icd $out/etc/OpenCL/vendors/ - - mkdir -p "$out/share/vulkan/icd.d" - cp -p nvidia_icd.json "$out/share/vulkan/icd.d/" - mkdir -p "$out/lib" cp -prd *.so.* tls "$out/lib/" - rm "$out"/lib/lib{glx,nvidia-wfb}.so.* # handled separately + rm $out/lib/lib{glx,nvidia-wfb}.so.* # handled separately + rm -f $out/lib/libnvidia-gtk* # built from source + if [ "$useGLVND" = "1" ]; then + # Pre-built libglvnd + rm $out/lib/lib{GL,GLX,EGL,GLESv1_CM,GLESv2,OpenGL,GLdispatch}.so.* + fi + # Use ocl-icd instead + rm $out/lib/libOpenCL.so* + # Move VDPAU libraries to their place + mkdir $out/lib/vdpau + mv $out/lib/libvdpau* $out/lib/vdpau - rm $out/lib/libGL.so.1.* # GLVND - rm $out/lib/libOpenCL.so* # ocl-icd is used instead + # Install ICDs. + install -Dm644 nvidia.icd $out/etc/OpenCL/vendors/nvidia.icd + if [ -e nvidia_icd.json ]; then + install -Dm644 nvidia_icd.json $out/share/vulkan/icd.d/nvidia.json + fi + if [ "$useGLVND" = "1" ]; then + install -Dm644 10_nvidia.json $out/share/glvnd/egl_vendor.d/nvidia.json + fi - if test -z "$libsOnly"; then + if [ -n "$bin" ]; then # Install the X drivers. - 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 + mkdir -p $bin/lib/xorg/modules + cp -p libnvidia-wfb.* $bin/lib/xorg/modules/ + mkdir -p $bin/lib/xorg/modules/drivers + cp -p nvidia_drv.so $bin/lib/xorg/modules/drivers + mkdir -p $bin/lib/xorg/modules/extensions + cp -p libglx.so.* $bin/lib/xorg/modules/extensions # Install the kernel module. - mkdir -p $out/lib/modules/$kernelVersion/misc + mkdir -p $bin/lib/modules/$kernelVersion/misc for i in $(find ./kernel -name '*.ko'); do nuke-refs $i - cp $i $out/lib/modules/$kernelVersion/misc/ + cp $i $bin/lib/modules/$kernelVersion/misc/ done fi - # All libs except GUI-only are in $out now, so fixup them. - for libname in `find "$out/lib/" -name '*.so.*'` + # All libs except GUI-only are installed now, so fixup them. + for libname in `find "$out/lib/" -name '*.so.*'` `find "$bin/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" + patchelf --set-rpath "$out/lib:$libPath" "$libname" libname_short=`echo -n "$libname" | sed 's/so\..*/so/'` @@ -82,55 +94,23 @@ installPhase() { fi 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.*.* - - if test -z "$libsOnly"; then - # Install headers and /share 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 - + if [ -n "$bin" ]; then + # Install /share files. + mkdir -p $bin/share/man/man1 + cp -p *.1.gz $bin/share/man/man1 + rm -f $bin/share/man/man1/{nvidia-xconfig,nvidia-settings,nvidia-persistenced}.1.gz # Install the programs. - mkdir -p $out/bin - - for i in nvidia-settings nvidia-smi; do - cp $i $out/bin/$i - patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ - --set-rpath $out/lib:$programPath:$glPath $out/bin/$i + for i in nvidia-cuda-mps-control nvidia-cuda-mps-server nvidia-smi nvidia-debugdump; do + if [ -e "$i" ]; then + install -Dm755 $i $bin/bin/$i + patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath $out/lib:$libPath $bin/bin/$i + fi done - - patchelf --set-rpath $glPath:$gtkPath $out/lib/libnvidia-gtk2.so.*.* - - # Test a bit. - $out/bin/nvidia-settings --version - else - rm $out/lib/libnvidia-gtk2.* + # FIXME: needs PATH and other fixes + # install -Dm755 nvidia-bug-report.sh $bin/bin/nvidia-bug-report.sh fi - - # For simplicity and dependency reduction, don't support the gtk3 interface. - rm $out/lib/libnvidia-gtk3.* - - # Move VDPAU libraries to their place - mkdir "$out"/lib/vdpau - mv "$out"/lib/libvdpau* "$out"/lib/vdpau } diff --git a/pkgs/os-specific/linux/nvidia-x11/default.nix b/pkgs/os-specific/linux/nvidia-x11/default.nix index 967a98d95663..204ef62138a1 100644 --- a/pkgs/os-specific/linux/nvidia-x11/default.nix +++ b/pkgs/os-specific/linux/nvidia-x11/default.nix @@ -1,74 +1,43 @@ -{ stdenv, fetchurl, kernel ? null, xorg, zlib, perl -, gtk2, atk, pango, glib, gdk_pixbuf, cairo, nukeReferences -, # 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; +{ callPackage }: let - - versionNumber = "375.26"; - - # Policy: use the highest stable version as the default (on our master). - inherit (stdenv.lib) makeLibraryPath; - - nameSuffix = optionalString (!libsOnly) "-${kernel.version}"; - + generic = args: callPackage (import ./generic.nix args) { }; in - -stdenv.mkDerivation { - name = "nvidia-x11-${versionNumber}${nameSuffix}"; - - builder = ./builder.sh; - - src = - if stdenv.system == "i686-linux" then - fetchurl { - url = "http://download.nvidia.com/XFree86/Linux-x86/${versionNumber}/NVIDIA-Linux-x86-${versionNumber}.run"; - sha256 = "0yv19rkz2wzzj0fygfjb1mh21iy769kff3yg2kzk8bsiwnmcyybw"; - } - else if stdenv.system == "x86_64-linux" then - fetchurl { - url = "http://download.nvidia.com/XFree86/Linux-x86_64/${versionNumber}/NVIDIA-Linux-x86_64-${versionNumber}.run"; - sha256 = "1kqy9ayja3g5znj2hzx8pklz8qi0b0l9da7c3ldg3hlxf31v4hjg"; - } - else throw "nvidia-x11 does not support platform ${stdenv.system}"; - - inherit versionNumber libsOnly; - inherit (stdenv) system; - - kernel = if libsOnly then null else kernel.dev; - - hardeningDisable = [ "pic" "format" ]; - - dontStrip = true; - - glPath = makeLibraryPath [xorg.libXext xorg.libX11 xorg.libXrandr]; - cudaPath = makeLibraryPath [zlib stdenv.cc.cc]; - openclPath = makeLibraryPath [zlib]; - allLibPath = makeLibraryPath [xorg.libXext xorg.libX11 xorg.libXrandr zlib stdenv.cc.cc]; - - gtkPath = optionalString (!libsOnly) (makeLibraryPath - [ gtk2 atk pango glib gdk_pixbuf cairo ] ); - programPath = makeLibraryPath [ xorg.libXv ]; - - - - buildInputs = [ perl nukeReferences ]; - - disallowedReferences = if libsOnly then [] else [ kernel.dev ]; - - 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 ]; - priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so" +{ + # Policy: use the highest stable version as the default (on our master). + stable = generic { + version = "375.26"; + sha256_32bit = "0yv19rkz2wzzj0fygfjb1mh21iy769kff3yg2kzk8bsiwnmcyybw"; + sha256_64bit = "1kqy9ayja3g5znj2hzx8pklz8qi0b0l9da7c3ldg3hlxf31v4hjg"; + settingsSha256 = "1s8zf5cfhx8m05fvws0gh1q0wy5zyyg2j510zlwp4hk35y7dic5y"; + persistencedSha256 = "15r6rbzyk4yaqkpkqs8j00zc7jbhgp8naskv93dwjyw0lnj0wgky"; }; + + beta = generic { + version = "378.09"; + sha256_32bit = "0a1vwvsqi89pn29c9aii53xq8292dxf68sr8lxzx4bpqjqmsbapy"; + sha256_64bit = "018qqg9zlpwd2cad99vbn18rnrrkrqybs7q65h8dmxirkx4pcvh8"; + settingsSha256 = "1fjkpqmzdzk46p1chzxqvbj3cpqcwwx4qmv33yjq7z2a5zab9z8v"; + persistencedSha256 = "1svaa5a0zz0r8qy6pg9lnhy5zmffvw0h120h46qqd01pkb4yv5lc"; + }; + + legacy_340 = generic { + version = "340.101"; + sha256_32bit = "0qmhkvxj6h63sayys9gldpafw5skpv8nsm2gxxb3pxcv7nfdlpjz"; + sha256_64bit = "02k8j0xzxp2y4vay0kf982q382ny1i4g1kai93f2h5sak6sq3kyj"; + settingsSha256 = "1mavbhff24n0jn154af152fp04njd505scdlxdm850h1ycb2i3g9"; + persistencedSha256 = "1396bmmg9b1z805dzljgi2f219ji84wfnnifdbk32dpd5mrywjk0"; + useGLVND = false; + }; + + legacy_304 = generic { + version = "304.134"; + sha256_32bit = "178wx0a2pmdnaypa9pq6jh0ii0i8ykz1sh1liad9zfriy4d8kxw4"; + sha256_64bit = "0pydw7nr4d2dply38kwvjbghsbilbp2q0mas4nfq5ad050d2c550"; + settingsSha256 = "0q92xw4fr9p5nbhj1plynm50d32881861daxfwrisywszqijhmlf"; + persistencedSha256 = null; + useGLVND = false; + }; + + legacy_173 = callPackage ./legacy173.nix { }; } diff --git a/pkgs/os-specific/linux/nvidia-x11/generic.nix b/pkgs/os-specific/linux/nvidia-x11/generic.nix new file mode 100644 index 000000000000..1398dae0e64f --- /dev/null +++ b/pkgs/os-specific/linux/nvidia-x11/generic.nix @@ -0,0 +1,81 @@ +{ version +, sha256_32bit +, sha256_64bit +, settingsSha256 +, persistencedSha256 +, useGLVND ? true +, preferGtk2 ? false +}: + +{ stdenv, callPackage, callPackage_i686, buildEnv, fetchurl +, kernel ? null, xorg, zlib, perl, nukeReferences +, # 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 + nameSuffix = optionalString (!libsOnly) "-${kernel.version}"; + pkgSuffix = optionalString (versionOlder version "304") "-pkg0"; + + self = stdenv.mkDerivation { + name = "nvidia-x11-${version}${nameSuffix}"; + + builder = ./builder.sh; + + src = + if stdenv.system == "i686-linux" then + fetchurl { + url = "http://download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run"; + sha256 = sha256_32bit; + } + else if stdenv.system == "x86_64-linux" then + fetchurl { + url = "http://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run"; + sha256 = sha256_64bit; + } + else throw "nvidia-x11 does not support platform ${stdenv.system}"; + + inherit version useGLVND; + inherit (stdenv) system; + + outputs = [ "out" ] ++ optional (!libsOnly) "bin"; + outputDev = if libsOnly then null else "bin"; + + kernel = if libsOnly then null else kernel.dev; + + hardeningDisable = [ "pic" "format" ]; + + dontStrip = true; + dontPatchELF = true; + + libPath = makeLibraryPath [ xorg.libXext xorg.libX11 xorg.libXv xorg.libXrandr zlib stdenv.cc.cc ]; + + nativeBuildInputs = [ perl nukeReferences ]; + + disallowedReferences = optional (!libsOnly) [ kernel.dev ]; + + passthru = { + settings = callPackage (import ./settings.nix self settingsSha256) { + withGtk2 = preferGtk2; + withGtk3 = !preferGtk2; + }; + persistenced = if persistencedSha256 == null then null else callPackage (import ./persistenced.nix self persistencedSha256) { }; + }; + + meta = with stdenv.lib; { + 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 ]; + priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so" + }; + }; + +in self diff --git a/pkgs/os-specific/linux/nvidia-x11/legacy173.nix b/pkgs/os-specific/linux/nvidia-x11/legacy173.nix index d1f6d36a6a7e..19199579e77f 100644 --- a/pkgs/os-specific/linux/nvidia-x11/legacy173.nix +++ b/pkgs/os-specific/linux/nvidia-x11/legacy173.nix @@ -38,6 +38,12 @@ stdenv.mkDerivation { programPath = stdenv.lib.makeLibraryPath [ gtk2 atk pango glib gdk_pixbuf xorg.libXv ]; + passthru = { + settings = null; + persistenced = null; + useGLVND = false; + }; + meta = { homepage = http://www.nvidia.com/object/unix.html; description = "X.org driver and kernel module for Legacy NVIDIA graphics cards"; diff --git a/pkgs/os-specific/linux/nvidia-x11/legacy304.nix b/pkgs/os-specific/linux/nvidia-x11/legacy304.nix deleted file mode 100644 index a6728f40cdac..000000000000 --- a/pkgs/os-specific/linux/nvidia-x11/legacy304.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ stdenv, fetchurl, kernel ? null, xorg, zlib, perl -, gtk2, 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; - -let versionNumber = "304.134"; in - -stdenv.mkDerivation { - name = "nvidia-x11-${versionNumber}${optionalString (!libsOnly) "-${kernel.version}"}"; - - builder = ./builder-legacy304.sh; - - src = - if stdenv.system == "i686-linux" then - fetchurl { - url = "http://download.nvidia.com/XFree86/Linux-x86/${versionNumber}/NVIDIA-Linux-x86-${versionNumber}.run"; - sha256 = "178wx0a2pmdnaypa9pq6jh0ii0i8ykz1sh1liad9zfriy4d8kxw4"; - } - else if stdenv.system == "x86_64-linux" then - fetchurl { - url = "http://download.nvidia.com/XFree86/Linux-x86_64/${versionNumber}/NVIDIA-Linux-x86_64-${versionNumber}-no-compat32.run"; - sha256 = "0hy4q1v4y7q2jq2j963mwpjhjksqhaiing3xcla861r8rmjkf8a2"; - } - else throw "nvidia-x11 does not support platform ${stdenv.system}"; - - inherit versionNumber libsOnly; - - kernel = if libsOnly then null else kernel.dev; - - hardeningDisable = [ "pic" "format" ]; - - dontStrip = true; - - glPath = stdenv.lib.makeLibraryPath [xorg.libXext xorg.libX11 xorg.libXrandr]; - - cudaPath = stdenv.lib.makeLibraryPath [zlib stdenv.cc.cc]; - - programPath = optionalString (!libsOnly) (stdenv.lib.makeLibraryPath - [ gtk2 atk pango glib gdk_pixbuf xorg.libXv ] ); - - buildInputs = [ perl ]; - - meta = { - homepage = http://www.nvidia.com/object/unix.html; - description = "X.org driver and kernel module for NVIDIA graphics cards"; - license = stdenv.lib.licenses.unfree; - }; -} diff --git a/pkgs/os-specific/linux/nvidia-x11/legacy340.nix b/pkgs/os-specific/linux/nvidia-x11/legacy340.nix deleted file mode 100644 index 5707fc4a1eb4..000000000000 --- a/pkgs/os-specific/linux/nvidia-x11/legacy340.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ stdenv, fetchurl, kernel ? null, xorg, zlib, perl -, gtk2, 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 = "340.101"; - /* 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-legacy340.sh; - - src = - if stdenv.system == "i686-linux" then - fetchurl { - url = "http://download.nvidia.com/XFree86/Linux-x86/${versionNumber}/NVIDIA-Linux-x86-${versionNumber}.run"; - sha256 = "0qmhkvxj6h63sayys9gldpafw5skpv8nsm2gxxb3pxcv7nfdlpjz"; - } - else if stdenv.system == "x86_64-linux" then - fetchurl { - url = "http://download.nvidia.com/XFree86/Linux-x86_64/${versionNumber}/NVIDIA-Linux-x86_64-${versionNumber}-no-compat32.run"; - sha256 = "0ln7fxm78zrzrjk3j5ychi5xxlgkzg2m7anw8nklr3d17c3jxxjy"; - } - else throw "nvidia-x11 does not support platform ${stdenv.system}"; - - inherit versionNumber libsOnly; - - kernel = if libsOnly then null else kernel.dev; - - hardeningDisable = [ "pic" "format" ]; - - dontStrip = true; - - glPath = makeLibraryPath [xorg.libXext xorg.libX11 xorg.libXrandr]; - cudaPath = makeLibraryPath [zlib stdenv.cc.cc]; - openclPath = makeLibraryPath [zlib]; - allLibPath = makeLibraryPath [xorg.libXext xorg.libX11 xorg.libXrandr zlib stdenv.cc.cc]; - - programPath = optionalString (!libsOnly) (makeLibraryPath - [ gtk2 atk pango glib gdk_pixbuf xorg.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 ]; - priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so" - }; -} diff --git a/pkgs/os-specific/linux/nvidia-x11/persistenced.nix b/pkgs/os-specific/linux/nvidia-x11/persistenced.nix new file mode 100644 index 000000000000..bc79e0efe63c --- /dev/null +++ b/pkgs/os-specific/linux/nvidia-x11/persistenced.nix @@ -0,0 +1,30 @@ +nvidia_x11: sha256: + +{ stdenv, lib, fetchurl, m4 }: + +stdenv.mkDerivation rec { + name = "nvidia-persistenced-${nvidia_x11.version}"; + inherit (nvidia_x11) version; + + src = fetchurl { + url = "ftp://download.nvidia.com/XFree86/nvidia-persistenced/${name}.tar.bz2"; + inherit sha256; + }; + + nativeBuildInputs = [ m4 ]; + + installFlags = [ "PREFIX=$(out)" ]; + + postFixup = '' + patchelf --set-rpath "$(patchelf --print-rpath $out/bin/nvidia-persistenced):${nvidia_x11}/lib" \ + $out/bin/nvidia-persistenced + ''; + + meta = with stdenv.lib; { + homepage = "http://www.nvidia.com/object/unix.html"; + description = "Settings application for NVIDIA graphics cards"; + license = licenses.unfreeRedistributable; + platforms = platforms.linux; + maintainers = with maintainers; [ abbradar ]; + }; +} diff --git a/pkgs/os-specific/linux/nvidia-x11/settings.nix b/pkgs/os-specific/linux/nvidia-x11/settings.nix new file mode 100644 index 000000000000..de60c9ccf4f1 --- /dev/null +++ b/pkgs/os-specific/linux/nvidia-x11/settings.nix @@ -0,0 +1,51 @@ +nvidia_x11: sha256: + +{ stdenv, lib, fetchurl, pkgconfig, m4, gtk2, gtk3, libXv, libvdpau +, withGtk2 ? false, withGtk3 ? true +}: + +stdenv.mkDerivation rec { + name = "nvidia-settings-${nvidia_x11.version}"; + inherit (nvidia_x11) version; + + src = fetchurl { + url = "ftp://download.nvidia.com/XFree86/nvidia-settings/${name}.tar.bz2"; + inherit sha256; + }; + + nativeBuildInputs = [ pkgconfig m4 ]; + + buildInputs = [ gtk2 gtk3 libXv libvdpau ]; + + installFlags = [ "PREFIX=$(out)" ]; + + preBuild = '' + if [ -e src/libXNVCtrl/libXNVCtrl.a ]; then + ( cd src/libXNVCtrl + make + ) + fi + ''; + + postInstall = '' + ${lib.optionalString (!withGtk2) '' + rm -f $out/lib/libnvidia-gtk2.so.* + ''} + ${lib.optionalString (!withGtk3) '' + rm -f $out/lib/libnvidia-gtk3.so.* + ''} + ''; + + postFixup = '' + patchelf --set-rpath "$(patchelf --print-rpath $out/bin/nvidia-settings):$out/lib:${nvidia_x11}/lib" \ + $out/bin/nvidia-settings + ''; + + meta = with stdenv.lib; { + homepage = "http://www.nvidia.com/object/unix.html"; + description = "Settings application for NVIDIA graphics cards"; + license = licenses.unfreeRedistributable; + platforms = platforms.linux; + maintainers = with maintainers; [ abbradar ]; + }; +} diff --git a/pkgs/tools/X11/bumblebee/default.nix b/pkgs/tools/X11/bumblebee/default.nix index eac44efdf273..7b725bfeb57c 100644 --- a/pkgs/tools/X11/bumblebee/default.nix +++ b/pkgs/tools/X11/bumblebee/default.nix @@ -19,12 +19,13 @@ { stdenv, lib, fetchurl, fetchpatch, pkgconfig, help2man, makeWrapper , glib, libbsd , libX11, libXext, xorgserver, xkbcomp, kmod, xf86videonouveau -, nvidia_x11, virtualgl, primusLib +, nvidia_x11, virtualgl, libglvnd, primusLib , automake111x, autoconf # The below should only be non-null in a x86_64 system. On a i686 # system the above nvidia_x11 and virtualgl will be the i686 packages. # TODO: Confusing. Perhaps use "SubArch" instead of i686? , nvidia_x11_i686 ? null +, libglvnd_i686 ? null , primusLib_i686 ? null , useDisplayDevice ? false , extraNvidiaDeviceOptions ? "" @@ -40,7 +41,10 @@ let primusLibs = lib.makeLibraryPath ([primus] ++ lib.optional (primusLib_i686 != null) primus_i686); - nvidia_x11s = [nvidia_x11] ++ lib.optional (nvidia_x11_i686 != null) nvidia_x11_i686; + nvidia_x11s = [ nvidia_x11 ] + ++ lib.optional nvidia_x11.useGLVND libglvnd + ++ lib.optionals (nvidia_x11_i686 != null) + ([ nvidia_x11_i686 ] ++ lib.optional nvidia_x11_i686.useGLVND libglvnd_i686); nvidiaLibs = lib.makeLibraryPath nvidia_x11s; @@ -120,7 +124,7 @@ in stdenv.mkDerivation rec { #"CONF_PRIMUS_LD_PATH=${primusLibs}" ] ++ lib.optionals useNvidia [ "CONF_LDPATH_NVIDIA=${nvidiaLibs}" - "CONF_MODPATH_NVIDIA=${nvidia_x11}/lib/xorg/modules" + "CONF_MODPATH_NVIDIA=${nvidia_x11.bin}/lib/xorg/modules" ]; CFLAGS = [ diff --git a/pkgs/tools/X11/primus/default.nix b/pkgs/tools/X11/primus/default.nix index 88589a058783..229e228e405c 100644 --- a/pkgs/tools/X11/primus/default.nix +++ b/pkgs/tools/X11/primus/default.nix @@ -5,6 +5,8 @@ # Other distributions do the same. { stdenv , stdenv_i686 +, lib +, bumblebee , primusLib , writeScriptBin , primusLib_i686 ? null @@ -18,7 +20,7 @@ let primus = if useNvidia then primusLib_ else primusLib_.override { nvidia_x11 = null; }; primus_i686 = if useNvidia then primusLib_i686_ else primusLib_i686_.override { nvidia_x11 = null; }; - ldPath = stdenv.lib.makeLibraryPath ([primus] ++ stdenv.lib.optional (primusLib_i686 != null) primus_i686); + ldPath = lib.makeLibraryPath ([ primus primus.glvnd ] ++ lib.optionals (primusLib_i686 != null) [ primus_i686 primus_i686.glvnd ]); in writeScriptBin "primusrun" '' #!${stdenv.shell} diff --git a/pkgs/tools/X11/primus/lib.nix b/pkgs/tools/X11/primus/lib.nix index fccd01eaeadd..f3119a1a147b 100644 --- a/pkgs/tools/X11/primus/lib.nix +++ b/pkgs/tools/X11/primus/lib.nix @@ -1,10 +1,16 @@ -{ stdenv, fetchFromGitHub -, xlibsWrapper, mesa +{ stdenv, fetchFromGitHub, fetchpatch +, libX11, mesa_noglu , nvidia_x11 ? null -, libX11 +, libglvnd }: -stdenv.mkDerivation { +let + aPackage = + if nvidia_x11 == null then mesa_noglu + else if nvidia_x11.useGLVND then libglvnd + else nvidia_x11; + +in stdenv.mkDerivation { name = "primus-lib-2015-04-28"; src = fetchFromGitHub { @@ -14,18 +20,28 @@ stdenv.mkDerivation { sha256 = "118jm57ccawskb8vjq3a9dpa2gh72nxzvx2zk7zknpy0arrdznj1"; }; - buildInputs = [ libX11 mesa ]; + patches = [ + # Bump buffer size for long library paths. + (fetchpatch { + url = "https://github.com/abbradar/primus/commit/2f429e232581c556df4f4bf210aee8a0c99c60b7.patch"; + sha256 = "1da6ynz7r7x98495i329sf821308j1rpy8prcdraqahz7p4c89nc"; + }) + ]; + + buildInputs = [ libX11 mesa_noglu ]; makeFlags = [ "LIBDIR=$(out)/lib" - "PRIMUS_libGLa=${if nvidia_x11 == null then mesa else nvidia_x11}/lib/libGL.so" - "PRIMUS_libGLd=${mesa}/lib/libGL.so" - "PRIMUS_LOAD_GLOBAL=${mesa}/lib/libglapi.so" + "PRIMUS_libGLa=${aPackage}/lib/libGL.so" + "PRIMUS_libGLd=${mesa_noglu}/lib/libGL.so" + "PRIMUS_LOAD_GLOBAL=${mesa_noglu}/lib/libglapi.so" ]; installPhase = '' ln -s $out/lib/libGL.so.1 $out/lib/libGL.so ''; + passthru.glvnd = if nvidia_x11 != null && nvidia_x11.useGLVND then nvidia_x11 else null; + meta = with stdenv.lib; { description = "Low-overhead client-side GPU offloading"; homepage = "https://github.com/amonakov/primus"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 105890e654aa..8dfff8e831ed 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8077,6 +8077,8 @@ with pkgs; libgnome_keyring = callPackage ../development/libraries/libgnome-keyring { }; libgnome_keyring3 = gnome3.libgnome_keyring; + libglvnd = callPackage ../development/libraries/libglvnd { }; + libgnurl = callPackage ../development/libraries/libgnurl { }; libgringotts = callPackage ../development/libraries/libgringotts { }; @@ -11374,12 +11376,13 @@ with pkgs; nvidiabl = callPackage ../os-specific/linux/nvidiabl { }; - 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_beta = nvidia_x11; # latest beta is lower version ATM - # callPackage ../os-specific/linux/nvidia-x11/beta.nix { }; - nvidia_x11 = callPackage ../os-specific/linux/nvidia-x11 { }; + nvidiaPackages = callPackage ../os-specific/linux/nvidia-x11 { }; + + nvidia_x11_legacy173 = nvidiaPackages.legacy_173; + nvidia_x11_legacy304 = nvidiaPackages.legacy_304; + nvidia_x11_legacy340 = nvidiaPackages.legacy_340; + nvidia_x11_beta = nvidiaPackages.beta; + nvidia_x11 = nvidiaPackages.stable; rtl8723bs = callPackage ../os-specific/linux/rtl8723bs { }; @@ -15472,6 +15475,9 @@ with pkgs; primusLib_i686 = if system == "x86_64-linux" then pkgsi686Linux.primusLib else null; + libglvnd_i686 = if system == "x86_64-linux" + then pkgsi686Linux.libglvnd + else null; }; vkeybd = callPackage ../applications/audio/vkeybd {};