nixpkgs/pkgs/os-specific/linux/nvidia-x11/builder.sh

112 lines
3.5 KiB
Bash
Raw Normal View History

source $stdenv/setup
dontPatchELF=1 # must keep libXv, $out in RPATH
unpackFile() {
2013-05-14 12:47:01 +01:00
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() {
# Install libGL and friends.
mkdir -p $out/lib/vendors
for f in \
libcuda libGL libnvcuvid libnvidia-cfg libnvidia-compiler \
libnvidia-encode libnvidia-glcore libnvidia-ml libnvidia-opencl \
libnvidia-tls libOpenCL libnvidia-tls libvdpau_nvidia libEGL libGLESv2
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.*.*
2013-02-01 12:57:59 +00:00
patchelf --set-rpath $openclPath $out/lib/libnvidia-opencl.so.*.*
2012-11-23 10:11:01 +00:00
if test -z "$libsOnly"; then
2012-11-23 10:11:01 +00:00
# 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
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-smi; do
2014-05-22 11:51:55 +01:00
cp $i $out/bin/$i
patchelf --interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" \
--set-rpath $out/lib:$programPath:$glPath $out/bin/$i
done
2012-11-23 10:11:01 +00:00
# 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
2014-05-22 11:51:55 +01:00
# Test a bit.
$out/bin/nvidia-settings --version
fi
}
genericBuild