summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xpkgs/os-specific/linux/nvidia-x11/builder.sh97
-rw-r--r--pkgs/os-specific/linux/nvidia-x11/default.nix25
-rw-r--r--pkgs/top-level/all-packages.nix2
3 files changed, 68 insertions, 56 deletions
diff --git a/pkgs/os-specific/linux/nvidia-x11/builder.sh b/pkgs/os-specific/linux/nvidia-x11/builder.sh
index 772f72f4cd8..6941288b390 100755
--- a/pkgs/os-specific/linux/nvidia-x11/builder.sh
+++ b/pkgs/os-specific/linux/nvidia-x11/builder.sh
@@ -9,33 +9,34 @@ unpackFile() {
 
 
 buildPhase() {
-    echo "Building linux driver against kernel: " $kernel;
-
-    cd usr/src/nv/
-
-    # Workaround: get it to build on kernels that have CONFIG_XEN set.
-    # Disable the test, apply a patch to disable the Xen functionality.
-    #substituteInPlace Makefile.kbuild --replace xen_sanity_check fnord
-    #patch -p1 < $xenPatch
-
-    # Create the module.
-    kernelVersion=$(cd $kernel/lib/modules && ls)
-    sysSrc=$(echo $kernel/lib/modules/$kernelVersion/build/)
-    unset src # used by the nv makefile
-    # Hack necessary to compile on 2.6.28.
-    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$sysSrc/include/asm/mach-default"
-    make SYSSRC=$sysSrc module
-    cd ../../..
+    if test -z "$libsOnly"; then
+        echo "Building linux driver against kernel: " $kernel;
+
+        cd usr/src/nv/
+
+        # Workaround: get it to build on kernels that have CONFIG_XEN
+        # set.  Disable the test, apply a patch to disable the Xen
+        # functionality.
+        
+        #substituteInPlace Makefile.kbuild --replace xen_sanity_check fnord
+        #patch -p1 < $xenPatch
+
+        # Create the module.
+        kernelVersion=$(cd $kernel/lib/modules && ls)
+        sysSrc=$(echo $kernel/lib/modules/$kernelVersion/build/)
+        unset src # used by the nv makefile
+        # Hack necessary to compile on 2.6.28.
+        export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$sysSrc/include/asm/mach-default"
+        make SYSSRC=$sysSrc module
+        cd ../../..
+    fi
 }
 
 
 installPhase() {
 
-    # Install the kernel module.
-    ensureDir $out/lib/modules/$kernelVersion/misc
-    cp usr/src/nv/nvidia.ko $out/lib/modules/$kernelVersion/misc
-
     # Install libGL and friends.
+    ensureDir $out/lib
     cp -prd usr/lib/* usr/X11R6/lib/libXv* $out/lib/
 
     ln -snf libGLcore.so.$versionNumber $out/lib/libGLcore.so
@@ -48,37 +49,45 @@ installPhase() {
     ln -snf libXvMCNVIDIA.so.$versionNumber $out/lib/libXvMCNVIDIA_dynamic.so.1
     ln -snf libcuda.so.$versionNumber $out/lib/libcuda.so.1
 
-    # Install the X driver.
-    ensureDir $out/lib/xorg/modules
-    cp -prd usr/X11R6/lib/modules/* $out/lib/xorg/modules/
-
-    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
-
-    # Install the programs.
-    ensureDir $out/bin
-
     patchelf --set-rpath $out/lib:$glPath $out/lib/libGL.so.*.*
     patchelf --set-rpath $out/lib:$glPath $out/lib/libXvMCNVIDIA.so.*.*
     set +e
     # Legacy nvidia doesn't have cuda
     patchelf --set-rpath $cudaPath $out/lib/libcuda.so.*.*
     set -e
-    patchelf --set-rpath $out/lib $out/lib/xorg/modules/extensions/libglx.so.*.*
-
-    for i in nvidia-settings nvidia-xconfig; do
-	cp usr/bin/$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.
-    cp -prd usr/include usr/share $out
+    if test -z "$libsOnly"; then
+        
+        # Install the kernel module.
+        ensureDir $out/lib/modules/$kernelVersion/misc
+        cp usr/src/nv/nvidia.ko $out/lib/modules/$kernelVersion/misc
 
-    # Patch the `nvidia-settings.desktop' file.
-    substituteInPlace $out/share/applications/nvidia-settings.desktop \
-        --replace '__UTILS_PATH__' $out/bin \
-        --replace '__PIXMAP_PATH__' $out/share/pixmaps
+        # Install the X driver.
+        ensureDir $out/lib/xorg/modules
+        cp -prd usr/X11R6/lib/modules/* $out/lib/xorg/modules/
+
+        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.
+        ensureDir $out/bin
+
+        for i in nvidia-settings nvidia-xconfig; do
+	    cp usr/bin/$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.
+        cp -prd usr/include usr/share $out
+
+        # Patch the `nvidia-settings.desktop' file.
+        substituteInPlace $out/share/applications/nvidia-settings.desktop \
+            --replace '__UTILS_PATH__' $out/bin \
+            --replace '__PIXMAP_PATH__' $out/share/pixmaps
+    fi
 }
 
 
diff --git a/pkgs/os-specific/linux/nvidia-x11/default.nix b/pkgs/os-specific/linux/nvidia-x11/default.nix
index 68263c128af..bc88775b02f 100644
--- a/pkgs/os-specific/linux/nvidia-x11/default.nix
+++ b/pkgs/os-specific/linux/nvidia-x11/default.nix
@@ -1,13 +1,16 @@
-{stdenv, fetchurl, kernel, xlibs, gtkLibs, zlib, perl}:
+{ stdenv, fetchurl, kernel ? null, xlibs, gtkLibs, zlib, perl
+, # 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
+}:
 
-let 
+with stdenv.lib;
 
-  versionNumber = "195.36.24";
-
-in
+let versionNumber = "195.36.24"; in
 
 stdenv.mkDerivation {
-  name = "nvidia-x11-${versionNumber}-${kernel.version}";
+  name = "nvidia-x11-${versionNumber}${optionalString (!libsOnly) "-${kernel.version}"}";
   
   builder = ./builder.sh;
   
@@ -24,7 +27,9 @@ stdenv.mkDerivation {
       }
     else throw "nvidia-x11 does not support platform ${stdenv.system}";
 
-  inherit versionNumber kernel;
+  inherit versionNumber libsOnly;
+
+  kernel = if libsOnly then null else kernel;
 
   dontStrip = true;
 
@@ -32,10 +37,8 @@ stdenv.mkDerivation {
 
   cudaPath = stdenv.lib.makeLibraryPath [zlib stdenv.gcc.gcc];
 
-  programPath = stdenv.lib.makeLibraryPath [
-    gtkLibs.gtk gtkLibs.atk gtkLibs.pango gtkLibs.glib
-    xlibs.libXv
-  ];
+  programPath = optionalString (!libsOnly) (stdenv.lib.makeLibraryPath
+    [ gtkLibs.gtk gtkLibs.atk gtkLibs.pango gtkLibs.glib xlibs.libXv ] );
 
   buildInputs = [ perl ];
 
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 93651bd21a1..c9846a66c63 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -6419,7 +6419,7 @@ let
       inherit fetchurl stdenv builderDefs kernel lib;
     };
 
-    nvidia_x11 = import ../os-specific/linux/nvidia-x11 {
+    nvidia_x11 = makeOverridable (import ../os-specific/linux/nvidia-x11) {
       inherit stdenv fetchurl kernel xlibs gtkLibs zlib perl;
     };