2014-12-24 00:01:04 +01:00
|
|
|
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
|
2015-07-30 14:07:45 +02:00
|
|
|
|
2014-12-24 00:01:04 +01:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
installPhase() {
|
2015-02-21 16:05:09 +01:00
|
|
|
# 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
|
|
|
|
|
2015-02-24 13:08:08 +01:00
|
|
|
if test -z "$libsOnly"; 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
|
|
|
|
|
|
|
|
# Install the kernel module.
|
|
|
|
mkdir -p $out/lib/modules/$kernelVersion/misc
|
2015-07-30 14:07:45 +02:00
|
|
|
for i in $(find ./kernel -name '*.ko'); do
|
2015-07-26 12:11:17 +02:00
|
|
|
nuke-refs $i
|
|
|
|
cp $i $out/lib/modules/$kernelVersion/misc/
|
|
|
|
done
|
2015-02-24 13:08:08 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# All libs except GUI-only are in $out now, so fixup them.
|
2015-02-21 16:05:09 +01:00
|
|
|
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/'`
|
2015-07-28 07:54:09 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2016-01-09 20:01:51 +01:00
|
|
|
if [[ "$libname" != "$libname_short" ]]; then
|
|
|
|
ln -srnf "$libname" "$libname_short"
|
|
|
|
fi
|
|
|
|
if [[ "$libname" != "$libname_short.1" ]]; then
|
|
|
|
ln -srnf "$libname" "$libname_short.1"
|
|
|
|
fi
|
2015-02-21 16:05:09 +01:00
|
|
|
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.*.*
|
|
|
|
|
2014-12-24 00:01:04 +01:00
|
|
|
if test -z "$libsOnly"; then
|
2015-02-24 13:08:08 +01:00
|
|
|
# Install headers and /share files etc.
|
2014-12-24 00:01:04 +01:00
|
|
|
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
|
|
|
|
|
2015-02-24 13:08:08 +01:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2015-02-28 13:49:25 +01:00
|
|
|
patchelf --set-rpath $glPath:$gtkPath $out/lib/libnvidia-gtk2.so.*.*
|
2015-02-24 13:08:08 +01:00
|
|
|
|
2014-12-24 00:01:04 +01:00
|
|
|
# Test a bit.
|
|
|
|
$out/bin/nvidia-settings --version
|
2015-02-21 16:05:09 +01:00
|
|
|
else
|
2015-02-28 13:49:25 +01:00
|
|
|
rm $out/lib/libnvidia-gtk2.*
|
2014-12-24 00:01:04 +01:00
|
|
|
fi
|
2015-02-28 13:49:25 +01:00
|
|
|
|
|
|
|
# For simplicity and dependency reduction, don't support the gtk3 interface.
|
|
|
|
rm $out/lib/libnvidia-gtk3.*
|
2015-09-01 11:33:11 +02:00
|
|
|
|
|
|
|
# we distribute these separately in `libvdpau`
|
|
|
|
rm "$out"/lib/libvdpau{.*,_trace.*}
|
2014-12-24 00:01:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
genericBuild
|