2014-12-23 23:01:04 +00:00
|
|
|
source $stdenv/setup
|
|
|
|
|
2017-01-29 21:29:39 +00:00
|
|
|
unpackManually() {
|
2014-12-23 23:01:04 +00:00
|
|
|
skip=$(sed 's/^skip=//; t; d' $src)
|
|
|
|
tail -n +$skip $src | xz -d | tar xvf -
|
|
|
|
sourceRoot=.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-29 21:29:39 +00:00
|
|
|
unpackFile() {
|
|
|
|
sh $src -x || unpackManually
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-23 23:01:04 +00:00
|
|
|
buildPhase() {
|
2017-01-29 21:29:39 +00:00
|
|
|
if [ -n "$bin" ]; then
|
2014-12-23 23:01:04 +00:00
|
|
|
# Create the module.
|
|
|
|
echo "Building linux driver against kernel: $kernel";
|
|
|
|
cd kernel
|
|
|
|
sysSrc=$(echo $kernel/lib/modules/$kernelVersion/source)
|
|
|
|
sysOut=$(echo $kernel/lib/modules/$kernelVersion/build)
|
|
|
|
unset src # used by the nv makefile
|
2017-02-11 22:29:37 +00:00
|
|
|
make SYSSRC=$sysSrc SYSOUT=$sysOut module -j$NIX_BUILD_CORES
|
2015-07-30 13:07:45 +01:00
|
|
|
|
2014-12-23 23:01:04 +00:00
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-08-11 16:32:00 +01:00
|
|
|
|
2014-12-23 23:01:04 +00:00
|
|
|
installPhase() {
|
2015-02-21 15:05:09 +00:00
|
|
|
# Install libGL and friends.
|
2018-08-11 16:32:00 +01:00
|
|
|
|
|
|
|
# since version 391, 32bit libraries are bundled in the 32/ sub-directory
|
|
|
|
if [ "$i686bundled" = "1" ]; then
|
|
|
|
mkdir -p "$lib32/lib"
|
|
|
|
cp -prd 32/*.so.* 32/tls "$lib32/lib/"
|
|
|
|
fi
|
|
|
|
|
2017-01-19 23:50:32 +00:00
|
|
|
mkdir -p "$out/lib"
|
2015-02-21 15:05:09 +00:00
|
|
|
cp -prd *.so.* tls "$out/lib/"
|
2018-08-11 16:32:00 +01:00
|
|
|
|
|
|
|
for i in $lib32 $out; do
|
|
|
|
rm -f $i/lib/lib{glx,nvidia-wfb}.so.* # handled separately
|
|
|
|
rm -f $i/lib/libnvidia-gtk* # built from source
|
|
|
|
if [ "$useGLVND" = "1" ]; then
|
|
|
|
# Pre-built libglvnd
|
|
|
|
rm $i/lib/lib{GL,GLX,EGL,GLESv1_CM,GLESv2,OpenGL,GLdispatch}.so.*
|
|
|
|
fi
|
|
|
|
# Use ocl-icd instead
|
|
|
|
rm -f $i/lib/libOpenCL.so*
|
|
|
|
# Move VDPAU libraries to their place
|
|
|
|
mkdir $i/lib/vdpau
|
|
|
|
mv $i/lib/libvdpau* $i/lib/vdpau
|
|
|
|
|
|
|
|
# Install ICDs.
|
|
|
|
install -Dm644 nvidia.icd $i/etc/OpenCL/vendors/nvidia.icd
|
|
|
|
if [ -e nvidia_icd.json.template ]; then
|
|
|
|
sed "s#__NV_VK_ICD__#libGLX_nvidia.so#" nvidia_icd.json.template > nvidia_icd.json
|
|
|
|
install -Dm644 nvidia_icd.json $i/share/vulkan/icd.d/nvidia.json
|
|
|
|
fi
|
|
|
|
if [ "$useGLVND" = "1" ]; then
|
|
|
|
install -Dm644 10_nvidia.json $i/share/glvnd/egl_vendor.d/nvidia.json
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
|
2016-04-06 14:50:01 +01:00
|
|
|
|
2017-01-29 21:29:39 +00:00
|
|
|
if [ -n "$bin" ]; then
|
2015-02-24 12:08:08 +00:00
|
|
|
# Install the X drivers.
|
2017-01-29 21:29:39 +00:00
|
|
|
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
|
2018-08-11 16:32:00 +01:00
|
|
|
cp -p libglx*.so* $bin/lib/xorg/modules/extensions
|
2015-02-24 12:08:08 +00:00
|
|
|
|
|
|
|
# Install the kernel module.
|
2017-01-29 21:29:39 +00:00
|
|
|
mkdir -p $bin/lib/modules/$kernelVersion/misc
|
2015-07-30 13:07:45 +01:00
|
|
|
for i in $(find ./kernel -name '*.ko'); do
|
2015-07-26 11:11:17 +01:00
|
|
|
nuke-refs $i
|
2017-01-29 21:29:39 +00:00
|
|
|
cp $i $bin/lib/modules/$kernelVersion/misc/
|
2015-07-26 11:11:17 +01:00
|
|
|
done
|
2017-02-11 14:11:18 +00:00
|
|
|
|
|
|
|
# Install application profiles.
|
|
|
|
if [ "$useProfiles" = "1" ]; then
|
|
|
|
mkdir -p $bin/share/nvidia
|
|
|
|
cp nvidia-application-profiles-*-rc $bin/share/nvidia/nvidia-application-profiles-rc
|
|
|
|
cp nvidia-application-profiles-*-key-documentation $bin/share/nvidia/nvidia-application-profiles-key-documentation
|
|
|
|
fi
|
2015-02-24 12:08:08 +00:00
|
|
|
fi
|
|
|
|
|
2017-01-29 21:29:39 +00:00
|
|
|
# All libs except GUI-only are installed now, so fixup them.
|
2018-08-11 16:32:00 +01:00
|
|
|
for libname in $(find "$out/lib/" $(test -n "$lib32" && echo "$lib32/lib/") $(test -n "$bin" && echo "$bin/lib/") -name '*.so.*')
|
2015-02-21 15:05:09 +00:00
|
|
|
do
|
|
|
|
# I'm lazy to differentiate needed libs per-library, as the closure is the same.
|
|
|
|
# Unfortunately --shrink-rpath would strip too much.
|
2017-01-29 21:29:39 +00:00
|
|
|
patchelf --set-rpath "$out/lib:$libPath" "$libname"
|
2015-02-21 15:05:09 +00:00
|
|
|
|
|
|
|
libname_short=`echo -n "$libname" | sed 's/so\..*/so/'`
|
2015-07-28 06:54:09 +01:00
|
|
|
|
2016-01-09 19:01:51 +00:00
|
|
|
if [[ "$libname" != "$libname_short" ]]; then
|
|
|
|
ln -srnf "$libname" "$libname_short"
|
|
|
|
fi
|
2016-04-06 14:50:01 +01:00
|
|
|
|
2017-01-29 03:47:25 +00:00
|
|
|
if [[ $libname_short =~ libEGL.so || $libname_short =~ libEGL_nvidia.so || $libname_short =~ libGLX.so || $libname_short =~ libGLX_nvidia.so ]]; then
|
2016-04-06 14:50:01 +01:00
|
|
|
major=0
|
|
|
|
else
|
|
|
|
major=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$libname" != "$libname_short.$major" ]]; then
|
|
|
|
ln -srnf "$libname" "$libname_short.$major"
|
2016-01-09 19:01:51 +00:00
|
|
|
fi
|
2015-02-21 15:05:09 +00:00
|
|
|
done
|
|
|
|
|
2017-01-29 21:29:39 +00:00
|
|
|
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
|
2015-02-24 12:08:08 +00:00
|
|
|
|
|
|
|
# Install the programs.
|
2017-01-29 21:29:39 +00:00
|
|
|
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
|
2015-02-24 12:08:08 +00:00
|
|
|
done
|
2017-01-29 21:29:39 +00:00
|
|
|
# FIXME: needs PATH and other fixes
|
|
|
|
# install -Dm755 nvidia-bug-report.sh $bin/bin/nvidia-bug-report.sh
|
2014-12-23 23:01:04 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
genericBuild
|