push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,243 @@
unpackManually() {
skip=$(sed 's/^skip=//; t; d' $src)
tail -n +$skip $src | bsdtar xvf -
sourceRoot=.
}
unpackFile() {
sh $src -x || unpackManually
}
buildPhase() {
runHook preBuild
if [ -n "$bin" ]; then
# Create the module.
echo "Building linux driver against kernel: $kernel";
cd kernel
unset src # used by the nv makefile
make $makeFlags -j $NIX_BUILD_CORES module
cd ..
fi
runHook postBuild
}
installPhase() {
runHook preInstall
# Install libGL and friends.
# since version 391, 32bit libraries are bundled in the 32/ sub-directory
if [ "$i686bundled" = "1" ]; then
mkdir -p "$lib32/lib"
cp -prd 32/*.so.* "$lib32/lib/"
if [ -d 32/tls ]; then
cp -prd 32/tls "$lib32/lib/"
fi
fi
mkdir -p "$out/lib"
cp -prd *.so.* "$out/lib/"
if [ -d tls ]; then
cp -prd tls "$out/lib/"
fi
# Install systemd power management executables
if [ -e systemd/nvidia-sleep.sh ]; then
mv systemd/nvidia-sleep.sh ./
fi
if [ -e nvidia-sleep.sh ]; then
sed -E 's#(PATH=).*#\1"$PATH"#' nvidia-sleep.sh > nvidia-sleep.sh.fixed
install -Dm755 nvidia-sleep.sh.fixed $out/bin/nvidia-sleep.sh
fi
if [ -e systemd/system-sleep/nvidia ]; then
mv systemd/system-sleep/nvidia ./
fi
if [ -e nvidia ]; then
sed -E "s#/usr(/bin/nvidia-sleep.sh)#$out\\1#" nvidia > nvidia.fixed
install -Dm755 nvidia.fixed $out/lib/systemd/system-sleep/nvidia
fi
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
rm -f $i/lib/libnvidia-wayland-client* # 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
# Compatibility with openssl 1.1, unused
rm -f $i/lib/libnvidia-pkcs11.so*
# Install ICDs, make absolute paths.
# Be careful not to modify any original files because this runs twice.
# OpenCL
sed -E "s#(libnvidia-opencl)#$i/lib/\\1#" nvidia.icd > nvidia.icd.fixed
install -Dm644 nvidia.icd.fixed $i/etc/OpenCL/vendors/nvidia.icd
# Vulkan
if [ -e nvidia_icd.json.template ] || [ -e nvidia_icd.json ]; then
if [ -e nvidia_icd.json.template ]; then
# template patching for version < 435
sed "s#__NV_VK_ICD__#$i/lib/libGLX_nvidia.so#" nvidia_icd.json.template > nvidia_icd.json.fixed
else
sed -E "s#(libGLX_nvidia)#$i/lib/\\1#" nvidia_icd.json > nvidia_icd.json.fixed
fi
# nvidia currently only supports x86_64 and i686
if [ "$i" == "$lib32" ]; then
install -Dm644 nvidia_icd.json.fixed $i/share/vulkan/icd.d/nvidia_icd.i686.json
else
install -Dm644 nvidia_icd.json.fixed $i/share/vulkan/icd.d/nvidia_icd.x86_64.json
fi
fi
if [ -e nvidia_layers.json ]; then
sed -E "s#(libGLX_nvidia)#$i/lib/\\1#" nvidia_layers.json > nvidia_layers.json.fixed
install -Dm644 nvidia_layers.json.fixed $i/share/vulkan/implicit_layer.d/nvidia_layers.json
fi
# EGL
if [ "$useGLVND" = "1" ]; then
mkdir -p "$i/share/egl/egl_external_platform.d"
for icdname in $(find . -name '*_nvidia*.json')
do
cat "$icdname" | jq ".ICD.library_path |= \"$i/lib/\(.)\"" | tee "$i/share/egl/egl_external_platform.d/$icdname"
done
# glvnd icd
mkdir -p "$i/share/glvnd/egl_vendor.d"
mv "$i/share/egl/egl_external_platform.d/10_nvidia.json" "$i/share/glvnd/egl_vendor.d/10_nvidia.json"
if [[ -f "$i/share/egl/egl_external_platform.d/15_nvidia_gbm.json" ]]; then
mkdir -p $i/lib/gbm
ln -s $i/lib/libnvidia-allocator.so $i/lib/gbm/nvidia-drm_gbm.so
fi
fi
# Install libraries needed by Proton to support DLSS
for winelib in $(find . -name '*nvngx*.dll')
do
install -Dm644 -t $i/lib/nvidia/wine/ "$winelib"
done
done
# OptiX tries loading `$ORIGIN/nvoptix.bin` first
if [ -e nvoptix.bin ]; then
install -Dm444 -t $out/lib/ nvoptix.bin
fi
if [ -n "$bin" ]; then
# Install the X drivers.
mkdir -p $bin/lib/xorg/modules
if [ -f libnvidia-wfb.so ]; then
cp -p libnvidia-wfb.* $bin/lib/xorg/modules/
fi
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 $bin/lib/modules/$kernelVersion/misc
for i in $(find ./kernel -name '*.ko'); do
nuke-refs $i
cp $i $bin/lib/modules/$kernelVersion/misc/
done
# 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
fi
if [ -n "$firmware" ]; then
# Install the GSP firmware
install -Dm644 -t $firmware/lib/firmware/nvidia/$version firmware/gsp*.bin
fi
# All libs except GUI-only are installed now, so fixup them.
for libname in $(find "$out/lib/" $(test -n "$lib32" && echo "$lib32/lib/") $(test -n "$bin" && echo "$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.
if [[ -n $lib32 && $libname == "$lib32/lib/"* ]]; then
patchelf --set-rpath "$lib32/lib:$libPath32" "$libname"
else
patchelf --set-rpath "$out/lib:$libPath" "$libname"
fi
# Manually create the right symlinks for the libraries.
#
# We can't just use ldconfig, because it does not create libfoo.so symlinks,
# only libfoo.so.1.
# Also, the symlink chain must be libfoo.so -> libfoo.so.1 -> libfoo.so.123.45,
# or ldconfig will explode.
# See: https://github.com/bminor/glibc/blob/6f3f6c506cdaf981a4374f1f12863b98ac7fea1a/elf/ldconfig.c#L854-L877
libbase=$(basename "$libname")
libdir=$(dirname "$libname")
soname=$(patchelf --print-soname "$libname")
unversioned=${libbase/\.so\.[0-9\.]*/.so}
if [[ -n "$soname" ]]; then
if [[ "$soname" != "$libbase" ]]; then
ln -s "$libbase" "$libdir/$soname"
fi
if [[ "$soname" != "$unversioned" ]]; then
ln -s "$soname" "$libdir/$unversioned"
fi
fi
# FIXME: libglxserver_nvidia does not have a soname, but must still be symlinked
if [[ "$unversioned" == "libglxserver_nvidia.so" ]]; then
ln -s "$libbase" "$libdir/$unversioned"
fi
done
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
if [ -e "nvidia-dbus.conf" ]; then
install -Dm644 nvidia-dbus.conf $bin/share/dbus-1/system.d/nvidia-dbus.conf
fi
# Install the programs.
for i in nvidia-cuda-mps-control nvidia-cuda-mps-server nvidia-smi nvidia-debugdump nvidia-powerd; do
if [ -e "$i" ]; then
install -Dm755 $i $bin/bin/$i
# unmodified binary backup for mounting in containers
install -Dm755 $i $bin/origBin/$i
patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath $out/lib:$libPath $bin/bin/$i
fi
done
substituteInPlace nvidia-bug-report.sh \
--replace /bin/grep grep \
--replace /bin/ls ls
install -Dm755 nvidia-bug-report.sh $bin/bin/nvidia-bug-report.sh
fi
runHook postInstall
}
genericBuild

View File

@@ -0,0 +1,267 @@
{
lib,
callPackage,
fetchFromGitHub,
fetchgit,
fetchpatch,
stdenv,
pkgsi686Linux,
}:
let
generic =
args:
let
imported = import ./generic.nix args;
in
callPackage imported {
lib32 =
(pkgsi686Linux.callPackage imported {
libsOnly = true;
kernel = null;
}).out;
};
kernel =
# a hacky way of extracting parameters from callPackage
callPackage (
{
kernel,
libsOnly ? false,
}:
if libsOnly then { } else kernel
) { };
selectHighestVersion = a: b: if lib.versionOlder a.version b.version then b else a;
# https://forums.developer.nvidia.com/t/linux-6-7-3-545-29-06-550-40-07-error-modpost-gpl-incompatible-module-nvidia-ko-uses-gpl-only-symbol-rcu-read-lock/280908/19
rcu_patch = fetchpatch {
url = "https://github.com/gentoo/gentoo/raw/c64caf53/x11-drivers/nvidia-drivers/files/nvidia-drivers-470.223.02-gpl-pfn_valid.patch";
hash = "sha256-eZiQQp2S/asE7MfGvfe6dA/kdCvek9SYa/FFGp24dVg=";
};
# Fixes drm device not working with linux 6.12
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/712
drm_fop_flags_linux_612_patch = fetchpatch {
url = "https://github.com/Binary-Eater/open-gpu-kernel-modules/commit/8ac26d3c66ea88b0f80504bdd1e907658b41609d.patch";
hash = "sha256-+SfIu3uYNQCf/KXhv4PWvruTVKQSh4bgU1moePhe57U=";
};
# Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms
aurPatches = fetchgit {
url = "https://aur.archlinux.org/nvidia-390xx-utils.git";
rev = "94dffc01e23a93c354a765ea7ac64484a3ef96c1";
hash = "sha256-c94qXNZyMrSf7Dik7jvz2ECaGELqN7WEYNpnbUkzeeU=";
};
# https://github.com/NVIDIA/open-gpu-kernel-modules/issues/840
gpl_symbols_linux_615_patch = fetchpatch {
url = "https://github.com/CachyOS/kernel-patches/raw/914aea4298e3744beddad09f3d2773d71839b182/6.15/misc/nvidia/0003-Workaround-nv_vm_flags_-calling-GPL-only-code.patch";
hash = "sha256-YOTAvONchPPSVDP9eJ9236pAPtxYK5nAePNtm2dlvb4=";
stripLen = 1;
extraPrefix = "kernel/";
};
in
rec {
mkDriver = generic;
# Official Unix Drivers - https://www.nvidia.com/en-us/drivers/unix/
# Branch/Maturity data - http://people.freedesktop.org/~aplattner/nvidia-versions.txt
# Policy: use the highest stable version as the default (on our master).
stable = if stdenv.hostPlatform.system == "i686-linux" then legacy_390 else production;
production = generic {
version = "580.95.05";
sha256_64bit = "sha256-hJ7w746EK5gGss3p8RwTA9VPGpp2lGfk5dlhsv4Rgqc=";
sha256_aarch64 = "sha256-zLRCbpiik2fGDa+d80wqV3ZV1U1b4lRjzNQJsLLlICk=";
openSha256 = "sha256-RFwDGQOi9jVngVONCOB5m/IYKZIeGEle7h0+0yGnBEI=";
settingsSha256 = "sha256-F2wmUEaRrpR1Vz0TQSwVK4Fv13f3J9NJLtBe4UP2f14=";
persistencedSha256 = "sha256-QCwxXQfG/Pa7jSTBB0xD3lsIofcerAWWAHKvWjWGQtg=";
};
latest = selectHighestVersion production (generic {
version = "575.64.05";
sha256_64bit = "sha256-hfK1D5EiYcGRegss9+H5dDr/0Aj9wPIJ9NVWP3dNUC0=";
sha256_aarch64 = "sha256-GRE9VEEosbY7TL4HPFoyo0Ac5jgBHsZg9sBKJ4BLhsA=";
openSha256 = "sha256-mcbMVEyRxNyRrohgwWNylu45vIqF+flKHnmt47R//KU=";
settingsSha256 = "sha256-o2zUnYFUQjHOcCrB0w/4L6xI1hVUXLAWgG2Y26BowBE=";
persistencedSha256 = "sha256-2g5z7Pu8u2EiAh5givP5Q1Y4zk4Cbb06W37rf768NFU=";
});
beta = selectHighestVersion latest (generic {
version = "580.65.06";
sha256_64bit = "sha256-BLEIZ69YXnZc+/3POe1fS9ESN1vrqwFy6qGHxqpQJP8=";
sha256_aarch64 = "sha256-4CrNwNINSlQapQJr/dsbm0/GvGSuOwT/nLnIknAM+cQ=";
openSha256 = "sha256-BKe6LQ1ZSrHUOSoV6UCksUE0+TIa0WcCHZv4lagfIgA=";
settingsSha256 = "sha256-9PWmj9qG/Ms8Ol5vLQD3Dlhuw4iaFtVHNC0hSyMCU24=";
persistencedSha256 = "sha256-ETRfj2/kPbKYX1NzE0dGr/ulMuzbICIpceXdCRDkAxA=";
});
# Vulkan developer beta driver
# See here for more information: https://developer.nvidia.com/vulkan-driver
vulkan_beta = generic rec {
version = "580.94.02";
persistencedVersion = "580.95.05";
settingsVersion = "580.95.05";
sha256_64bit = "sha256-fhN062tzZq7OwkeRr1lRjhwkX6CH7fJ+oAKXdRTapGE=";
openSha256 = "sha256-MbxIJNBGYMesnero5VauMt5cKiNLw3cM9GxD4PnXM/o=";
settingsSha256 = "sha256-F2wmUEaRrpR1Vz0TQSwVK4Fv13f3J9NJLtBe4UP2f14=";
persistencedSha256 = "sha256-QCwxXQfG/Pa7jSTBB0xD3lsIofcerAWWAHKvWjWGQtg=";
url = "https://developer.nvidia.com/downloads/vulkan-beta-${lib.concatStrings (lib.splitVersion version)}-linux";
};
# data center driver compatible with current default cudaPackages
dc = dc_570;
dc_535 = generic rec {
version = "535.154.05";
url = "https://us.download.nvidia.com/tesla/${version}/NVIDIA-Linux-x86_64-${version}.run";
sha256_64bit = "sha256-fpUGXKprgt6SYRDxSCemGXLrEsIA6GOinp+0eGbqqJg=";
persistencedSha256 = "sha256-d0Q3Lk80JqkS1B54Mahu2yY/WocOqFFbZVBh+ToGhaE=";
fabricmanagerSha256 = "sha256-/HQfV7YA3MYVmre/sz897PF6tc6MaMiS/h7Q10m2p/o=";
useSettings = false;
usePersistenced = true;
useFabricmanager = true;
patches = [ rcu_patch ];
};
# Drop after next nixos release
dc_565 = generic rec {
version = "565.57.01";
url = "https://us.download.nvidia.com/tesla/${version}/NVIDIA-Linux-x86_64-${version}.run";
sha256_64bit = "sha256-buvpTlheOF6IBPWnQVLfQUiHv4GcwhvZW3Ks0PsYLHo=";
persistencedSha256 = "sha256-hdszsACWNqkCh8G4VBNitDT85gk9gJe1BlQ8LdrYIkg=";
fabricmanagerSha256 = "sha256-umhyehddbQ9+xhhoiKC7SOSVxscA5pcnqvkQOOLIdsM=";
useSettings = false;
usePersistenced = true;
useFabricmanager = true;
};
dc_570 = generic rec {
version = "570.172.08";
url = "https://us.download.nvidia.com/tesla/${version}/NVIDIA-Linux-x86_64-${version}.run";
sha256_64bit = "sha256-AlaGfggsr5PXsl+nyOabMWBiqcbHLG4ij617I4xvoX0=";
persistencedSha256 = "sha256-x4K0Gp89LdL5YJhAI0AydMRxl6fyBylEnj+nokoBrK8=";
fabricmanagerSha256 = "sha256-jSTKzeRVTUcYma1Cb0ajSdXKCi6KzUXCp2OByPSWSR4=";
useSettings = false;
usePersistenced = true;
useFabricmanager = true;
};
# Update note:
# If you add a legacy driver here, also update `top-level/linux-kernels.nix`,
# adding to the `nvidia_x11_legacy*` entries.
# Last one without the bug reported here:
# https://bbs.archlinux.org/viewtopic.php?pid=2155426#p2155426
legacy_535 = generic {
version = "535.261.03";
sha256_64bit = "sha256-10th0R6cm5BS9AQtbsRDfxPR3vMOlk4jLUfl1lnRHWg=";
sha256_aarch64 = "sha256-mkEtOsAcmdLKAhAKcTlZf86IBMUr9TPRG2BDcoaDSpM=";
openSha256 = "sha256-qUn0Kk9t6TZA6ZmUSPzqclOsU6n4Tp4dXkgGa1ZF+OA=";
settingsSha256 = "sha256-E05oCGuMdE3KhVrDl2ZQspaPqPHoVSwdaftoPKItYTE";
persistencedSha256 = "sha256-pnOq9+6l3BbIEKHboGeTwEcEcYhtESzmroUfCahqn0U=";
};
# Last one supporting Kepler architecture
legacy_470 = generic {
version = "470.256.02";
sha256_64bit = "sha256-1kUYYt62lbsER/O3zWJo9z6BFowQ4sEFl/8/oBNJsd4=";
sha256_aarch64 = "sha256-e+QvE+S3Fv3JRqC9ZyxTSiCu8gJdZXSz10gF/EN6DY0=";
settingsSha256 = "sha256-kftQ4JB0iSlE8r/Ze/+UMnwLzn0nfQtqYXBj+t6Aguk=";
persistencedSha256 = "sha256-iYoSib9VEdwjOPBP1+Hx5wCIMhW8q8cCHu9PULWfnyQ=";
patches = [
"${aurPatches}/gcc-14.patch"
# fixes 6.10 follow_pfn
./follow_pfn.patch
# https://gist.github.com/joanbm/a6d3f7f873a60dec0aa4a734c0f1d64e
(fetchpatch {
url = "https://gist.github.com/joanbm/a6d3f7f873a60dec0aa4a734c0f1d64e/raw/6bae5606c033b6c6c08233523091992370e357b7/nvidia-470xx-fix-linux-6.12.patch";
hash = "sha256-6nbzcRTRCxW8GDAhB8Zwx9rVcCzwPtVYlqoUhL9gxlY=";
stripLen = 1;
extraPrefix = "kernel/";
})
];
};
# Last one supporting x86
legacy_390 = generic {
version = "390.157";
sha256_32bit = "sha256-VdZeCkU5qct5YgDF8Qgv4mP7CVHeqvlqnP/rioD3B5k=";
sha256_64bit = "sha256-W+u8puj+1da52BBw+541HxjtxTSVJVPL3HHo/QubMoo=";
settingsSha256 = "sha256-uJZO4ak/w/yeTQ9QdXJSiaURDLkevlI81de0q4PpFpw=";
persistencedSha256 = "sha256-NuqUQbVt80gYTXgIcu0crAORfsj9BCRooyH3Gp1y1ns=";
patches = map (patch: "${aurPatches}/${patch}") [
"kernel-4.16+-memory-encryption.patch"
"kernel-6.2.patch"
"kernel-6.3.patch"
"kernel-6.4.patch"
"kernel-6.5.patch"
"kernel-6.6.patch"
"kernel-6.8.patch"
"gcc-14.patch"
"kernel-6.10.patch"
"kernel-6.12.patch"
];
broken = kernel.kernelAtLeast "6.13";
# fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
# see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
# and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
postInstall = ''
mv $out/lib/tls/* $out/lib
rmdir $out/lib/tls
'';
};
legacy_340 =
let
# Source corresponding to https://aur.archlinux.org/packages/nvidia-340xx-dkms
aurPatches = fetchFromGitHub {
owner = "archlinux-jerry";
repo = "nvidia-340xx";
rev = "7616dfed253aa93ca7d2e05caf6f7f332c439c90";
hash = "sha256-1qlYc17aEbLD4W8XXn1qKryBk2ltT6cVIv5zAs0jXZo=";
};
patchset = [
"0001-kernel-5.7.patch"
"0002-kernel-5.8.patch"
"0003-kernel-5.9.patch"
"0004-kernel-5.10.patch"
"0005-kernel-5.11.patch"
"0006-kernel-5.14.patch"
"0007-kernel-5.15.patch"
"0008-kernel-5.16.patch"
"0009-kernel-5.17.patch"
"0010-kernel-5.18.patch"
"0011-kernel-6.0.patch"
"0012-kernel-6.2.patch"
"0013-kernel-6.3.patch"
"0014-kernel-6.5.patch"
"0015-kernel-6.6.patch"
];
in
generic {
version = "340.108";
sha256_32bit = "1jkwa1phf0x4sgw8pvr9d6krmmr3wkgwyygrxhdazwyr2bbalci0";
sha256_64bit = "06xp6c0sa7v1b82gf0pq0i5p0vdhmm3v964v0ypw36y0nzqx8wf6";
settingsSha256 = "0zm29jcf0mp1nykcravnzb5isypm8l8mg2gpsvwxipb7nk1ivy34";
persistencedSha256 = "1ax4xn3nmxg1y6immq933cqzw6cj04x93saiasdc0kjlv0pvvnkn";
useGLVND = false;
broken = kernel.kernelAtLeast "6.7";
patches = map (patch: "${aurPatches}/${patch}") patchset;
# fixes the bug described in https://bbs.archlinux.org/viewtopic.php?pid=2083439#p2083439
# see https://bbs.archlinux.org/viewtopic.php?pid=2083651#p2083651
# and https://bbs.archlinux.org/viewtopic.php?pid=2083699#p2083699
postInstall = ''
mv $out/lib/tls/* $out/lib
rmdir $out/lib/tls
'';
};
}

View File

@@ -0,0 +1,69 @@
nvidia_x11: sha256:
{
stdenv,
lib,
fetchurl,
patchelf,
zlib,
glibc,
}:
let
sys = lib.concatStringsSep "-" (lib.reverseList (lib.splitString "-" stdenv.system));
bsys = builtins.replaceStrings [ "_" ] [ "-" ] sys;
fmver = nvidia_x11.fabricmanagerVersion;
ldd = (lib.getBin glibc) + "/bin/ldd";
in
stdenv.mkDerivation rec {
pname = "fabricmanager";
version = fmver;
src = fetchurl {
url =
"https://developer.download.nvidia.com/compute/nvidia-driver/redist/fabricmanager/"
+ "${sys}/${pname}-${sys}-${fmver}-archive.tar.xz";
inherit sha256;
};
phases = [
"unpackPhase"
"installPhase"
];
installPhase = ''
mkdir -p $out/{bin,share/nvidia-fabricmanager}
for bin in nv{-fabricmanager,switch-audit};do
${patchelf}/bin/patchelf \
--set-interpreter ${stdenv.cc.libc}/lib/ld-${bsys}.so.2 \
--set-rpath ${
lib.makeLibraryPath [
stdenv.cc.libc
zlib
]
} \
bin/$bin
done
mv bin/nv{-fabricmanager,switch-audit} $out/bin/.
for d in etc systemd share/nvidia;do
mv $d $out/share/nvidia-fabricmanager/.
done
for d in include lib;do
mv $d $out/.
done
patchShebangs $out/bin
for b in $out/bin/*;do
${ldd} $b | grep -vqz "not found"
done
'';
meta = {
homepage = "https://www.nvidia.com/object/unix.html";
description = "Fabricmanager daemon for NVLink intialization and control";
license = lib.licenses.unfreeRedistributable;
platforms = nvidia_x11.meta.platforms;
mainProgram = "nv-fabricmanager";
maintainers = with lib.maintainers; [ edwtjo ];
};
}

View File

@@ -0,0 +1,61 @@
diff -ruNb a/kernel/conftest.sh b/kernel/conftest.sh
--- a/kernel/conftest.sh 2024-07-19 04:36:26.183701185 -0500
+++ b/kernel/conftest.sh 2024-07-19 04:36:26.230366381 -0500
@@ -4464,20 +4464,22 @@
compile_check_conftest "$CODE" "NV_DRM_GEM_OBJECT_VMAP_HAS_MAP_ARG" "" "types"
;;
- unsafe_follow_pfn)
+ follow_pfn)
#
- # Determine if unsafe_follow_pfn() is present.
+ # Determine if follow_pfn() is present.
#
- # unsafe_follow_pfn() was added by commit 69bacee7f9ad
- # ("mm: Add unsafe_follow_pfn") in v5.13-rc1.
+ # follow_pfn() was added by commit 3b6748e2dd69
+ # ("mm: introduce follow_pfn()") in v2.6.31-rc1, and removed
+ # by commit 233eb0bf3b94 ("mm: remove follow_pfn")
+ # from linux-next 233eb0bf3b94.
#
CODE="
#include <linux/mm.h>
- void conftest_unsafe_follow_pfn(void) {
- unsafe_follow_pfn();
+ void conftest_follow_pfn(void) {
+ follow_pfn();
}"
- compile_check_conftest "$CODE" "NV_UNSAFE_FOLLOW_PFN_PRESENT" "" "functions"
+ compile_check_conftest "$CODE" "NV_FOLLOW_PFN_PRESENT" "" "functions"
;;
drm_plane_atomic_check_has_atomic_state_arg)
diff -ruNb a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
--- a/kernel/nvidia/nvidia.Kbuild 2022-10-12 04:29:57.000000000 -0500
+++ b/kernel/nvidia/nvidia.Kbuild 2024-07-19 05:17:39.148448922 -0500
@@ -164,7 +164,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += cc
NV_CONFTEST_FUNCTION_COMPILE_TESTS += iterate_fd
NV_CONFTEST_FUNCTION_COMPILE_TESTS += seq_read_iter
NV_CONFTEST_FUNCTION_COMPILE_TESTS += sg_page_iter_page
-NV_CONFTEST_FUNCTION_COMPILE_TESTS += unsafe_follow_pfn
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += follow_pfn
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_get
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_put_unlocked
NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_close_on_exec
diff -ruNb a/kernel/nvidia/os-mlock.c b/kernel/nvidia/os-mlock.c
--- a/kernel/nvidia/os-mlock.c 2022-10-12 04:30:26.000000000 -0500
+++ b/kernel/nvidia/os-mlock.c 2024-07-19 04:36:26.230366381 -0500
@@ -18,10 +18,10 @@
unsigned long address,
unsigned long *pfn)
{
-#if defined(NV_UNSAFE_FOLLOW_PFN_PRESENT)
- return unsafe_follow_pfn(vma, address, pfn);
-#else
+#if defined(NV_FOLLOW_PFN_PRESENT)
return follow_pfn(vma, address, pfn);
+#else
+ return -1;
#endif
}

View File

@@ -0,0 +1,348 @@
{
version,
url ? null,
sha256_32bit ? null,
sha256_64bit,
sha256_aarch64 ? null,
openSha256 ? null,
settingsSha256 ? null,
settingsVersion ? null,
persistencedSha256 ? null,
persistencedVersion ? null,
fabricmanagerSha256 ? null,
fabricmanagerVersion ? null,
useGLVND ? true,
useProfiles ? true,
preferGtk2 ? false,
settings32Bit ? false,
useSettings ? true,
usePersistenced ? true,
useFabricmanager ? false,
ibtSupport ? false,
prePatch ? null,
postPatch ? null,
patchFlags ? null,
patches ? [ ],
patchesOpen ? [ ],
preInstall ? null,
postInstall ? null,
broken ? false,
brokenOpen ? broken,
}@args:
{
lib,
stdenv,
runCommandLocal,
patchutils,
callPackage,
pkgs,
pkgsi686Linux,
fetchurl,
fetchzip,
kernel ? null,
kernelModuleMakeFlags ? [ ],
perl,
nukeReferences,
which,
libarchive,
jq,
# 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,
# don't include the bundled 32-bit libraries on 64-bit platforms,
# even if its in downloaded binary
disable32Bit ? stdenv.hostPlatform.system == "aarch64-linux",
# 32 bit libs only version of this package
lib32 ? null,
# Whether to extract the GSP firmware, datacenter drivers needs to extract the
# firmware
firmware ? openSha256 != null || useFabricmanager,
# Whether the user accepts the NVIDIA Software License
config,
acceptLicense ? config.nvidia.acceptLicense or false,
}:
assert !libsOnly -> kernel != null;
assert lib.versionOlder version "391" -> sha256_32bit != null;
assert useSettings -> settingsSha256 != null;
assert usePersistenced -> persistencedSha256 != null;
assert useFabricmanager -> fabricmanagerSha256 != null;
assert useFabricmanager -> !useSettings;
let
# Rewrites patches meant for the kernel/* folder structure to kernel-open/*
rewritePatch =
{ from, to }:
patch:
runCommandLocal (baseNameOf patch)
{
inherit patch;
nativeBuildInputs = [ patchutils ];
}
''
lsdiff \
-p1 -i ${from}/'*' \
"$patch" \
| sort -u | sed -e 's/[*?]/\\&/g' \
| xargs -I{} \
filterdiff \
--include={} \
--strip=2 \
--addoldprefix=a/${to}/ \
--addnewprefix=b/${to}/ \
--clean "$patch" > "$out"
'';
nameSuffix = lib.optionalString (!libsOnly) "-${kernel.version}";
pkgSuffix = lib.optionalString (lib.versionOlder version "304") "-pkg0";
i686bundled = lib.versionAtLeast version "391" && !disable32Bit;
libPathFor =
pkgs:
lib.makeLibraryPath (
with pkgs;
[
libdrm
xorg.libXext
xorg.libX11
xorg.libXv
xorg.libXrandr
xorg.libxcb
zlib
stdenv.cc.cc
wayland
libgbm
libGL
openssl
dbus # for nvidia-powerd
]
);
# maybe silly since we've ignored this previously and just unfree..
throwLicense = throw ''
Use of NVIDIA Software requires license acceptance of the license:
- License For Customer Use of NVIDIA Software [1]
You can express acceptance by setting acceptLicense to true your nixpkgs.config.
Example:
configuration.nix:
nixpkgs.config.allowUnfree = true;
nixpkgs.config.nvidia.acceptLicense = true;
config.nix:
allowUnfree = true;
nvidia.acceptLicense = true;
[1]: https://www.nvidia.com/content/DriverDownloads/licence.php?lang=us
'';
in
stdenv.mkDerivation (finalAttrs: {
name = "nvidia-${if useFabricmanager then "dc" else "x11"}-${version}${nameSuffix}";
builder = ./builder.sh;
src =
if !acceptLicense && (openSha256 == null) then
throwLicense
else if stdenv.hostPlatform.system == "x86_64-linux" then
fetchurl {
urls =
if args ? url then
[ args.url ]
else
[
"https://us.download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run"
"https://download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}${pkgSuffix}.run"
];
sha256 = sha256_64bit;
}
else if stdenv.hostPlatform.system == "i686-linux" then
fetchurl {
urls =
if args ? url then
[ args.url ]
else
[
"https://us.download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run"
"https://download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}${pkgSuffix}.run"
];
sha256 = sha256_32bit;
}
else if stdenv.hostPlatform.system == "aarch64-linux" && sha256_aarch64 != null then
fetchurl {
urls =
if args ? url then
[ args.url ]
else
[
"https://us.download.nvidia.com/XFree86/aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run"
"https://download.nvidia.com/XFree86/Linux-aarch64/${version}/NVIDIA-Linux-aarch64-${version}${pkgSuffix}.run"
];
sha256 = sha256_aarch64;
}
else
throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}";
patches = if libsOnly then null else patches;
inherit prePatch postPatch patchFlags;
inherit preInstall postInstall;
inherit version useGLVND useProfiles;
inherit (stdenv.hostPlatform) system;
inherit i686bundled;
outputs = [
"out"
]
++ lib.optional i686bundled "lib32"
++ lib.optional (!libsOnly) "bin"
++ lib.optional (!libsOnly && firmware) "firmware";
outputDev = if libsOnly then null else "bin";
kernel = if libsOnly then null else kernel.dev;
kernelVersion = if libsOnly then null else kernel.modDirVersion;
makeFlags = lib.optionals (!libsOnly) (
kernelModuleMakeFlags
++ [
"IGNORE_PREEMPT_RT_PRESENCE=1"
"NV_BUILD_SUPPORTS_HMM=1"
"SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
"SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
]
++ lib.optionals stdenv.cc.isClang [
"C_INCLUDE_PATH=${lib.getLib stdenv.cc.cc}/lib/clang/${lib.versions.major stdenv.cc.cc.version}/include"
]
);
hardeningDisable = [
"pic"
"format"
];
dontStrip = true;
dontPatchELF = true;
libPath = libPathFor pkgs;
libPath32 = lib.optionalString i686bundled (libPathFor pkgsi686Linux);
nativeBuildInputs = [
perl
nukeReferences
which
libarchive
jq
]
++ lib.optionals (!libsOnly) kernel.moduleBuildDependencies;
disallowedReferences = lib.optionals (!libsOnly) [ kernel.dev ];
passthru =
let
fetchFromGithubOrNvidia =
{
owner,
repo,
rev,
...
}@args:
let
args' = removeAttrs args [
"owner"
"repo"
"rev"
];
baseUrl = "https://github.com/${owner}/${repo}";
in
fetchzip (
args'
// {
urls = [
"${baseUrl}/archive/${rev}.tar.gz"
"https://download.nvidia.com/XFree86/${repo}/${repo}-${rev}.tar.bz2"
];
# github and nvidia use different compression algorithms,
# use an invalid file extension to force detection.
extension = "tar.??";
}
);
in
{
open = lib.mapNullable (
hash:
callPackage ./open.nix {
inherit hash;
nvidia_x11 = finalAttrs.finalPackage;
patches =
(map (rewritePatch {
from = "kernel";
to = "kernel-open";
}) patches)
++ patchesOpen;
broken = brokenOpen;
}
) openSha256;
settings =
if useSettings then
(if settings32Bit then pkgsi686Linux.callPackage else callPackage)
(import ./settings.nix finalAttrs.finalPackage settingsSha256)
{
withGtk2 = preferGtk2;
withGtk3 = !preferGtk2;
fetchFromGitHub = fetchFromGithubOrNvidia;
}
else
{ };
persistenced =
if usePersistenced then
lib.mapNullable (
hash:
callPackage (import ./persistenced.nix finalAttrs.finalPackage hash) {
fetchFromGitHub = fetchFromGithubOrNvidia;
}
) persistencedSha256
else
{ };
fabricmanager =
if useFabricmanager then
lib.mapNullable (
hash: callPackage (import ./fabricmanager.nix finalAttrs.finalPackage hash) { }
) fabricmanagerSha256
else
{ };
settingsVersion = if settingsVersion != null then settingsVersion else finalAttrs.version;
persistencedVersion =
if persistencedVersion != null then persistencedVersion else finalAttrs.version;
fabricmanagerVersion =
if fabricmanagerVersion != null then fabricmanagerVersion else finalAttrs.version;
compressFirmware = false;
ibtSupport = ibtSupport || (lib.versionAtLeast version "530");
}
// lib.optionalAttrs (!i686bundled) {
inherit lib32;
};
meta = with lib; {
homepage = "https://www.nvidia.com/object/unix.html";
description = "${
if useFabricmanager then "Data Center" else "X.org"
} driver and kernel module for NVIDIA cards";
license = licenses.unfreeRedistributable;
platforms = [
"x86_64-linux"
]
++ lib.optionals (sha256_32bit != null) [ "i686-linux" ]
++ lib.optionals (sha256_aarch64 != null) [ "aarch64-linux" ];
maintainers = with maintainers; [
kiskae
edwtjo
];
priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so"
inherit broken;
};
})

View File

@@ -0,0 +1,24 @@
--- a/src/libXNVCtrl/Makefile
+++ b/src/libXNVCtrl/Makefile
@@ -33,6 +33,8 @@
LIBXNVCTRL = libXNVCtrl.a
+LIBXNVCTRL_SHARED = $(OUTPUTDIR)/libXNVCtrl.so
+
LIBXNVCTRL_PROGRAM_NAME = "libXNVCtrl"
LIBXNVCTRL_VERSION := $(NVIDIA_VERSION)
@@ -62,6 +64,12 @@
$(LIBXNVCTRL) : $(OBJS)
$(AR) ru $@ $(OBJS)
+$(LIBXNVCTRL_SHARED): $(LIBXNVCTRL_OBJ)
+ $(RM) $@ $@.*
+ $(CC) -shared -Wl,-soname=$(@F).0 -o $@.0.0.0 $(LDFLAGS) $^ -lXext -lX11
+ ln -s $(@F).0.0.0 $@.0
+ ln -s $(@F).0 $@
+
# define the rule to build each object file
$(foreach src,$(SRC),$(eval $(call DEFINE_OBJECT_RULE,TARGET,$(src))))

View File

@@ -0,0 +1,21 @@
--- a/src/libXNVCtrl/xnvctrl.mk
+++ b/src/libXNVCtrl/xnvctrl.mk
@@ -39,6 +39,8 @@
LIBXNVCTRL = $(OUTPUTDIR)/libXNVCtrl.a
+LIBXNVCTRL_SHARED = $(OUTPUTDIR)/libXNVCtrl.so
+
LIBXNVCTRL_SRC = $(XNVCTRL_DIR)/NVCtrl.c
LIBXNVCTRL_OBJ = $(call BUILD_OBJECT_LIST,$(LIBXNVCTRL_SRC))
@@ -47,3 +49,9 @@
$(LIBXNVCTRL) : $(LIBXNVCTRL_OBJ)
$(call quiet_cmd,AR) ru $@ $(LIBXNVCTRL_OBJ)
+
+$(LIBXNVCTRL_SHARED): $(LIBXNVCTRL_OBJ)
+ $(RM) $@ $@.*
+ $(CC) -shared -Wl,-soname=$(@F).0 -o $@.0.0.0 $(LDFLAGS) $^ -lXext -lX11
+ ln -s $(@F).0.0.0 $@.0
+ ln -s $(@F).0 $@

View File

@@ -0,0 +1,64 @@
{
stdenv,
lib,
fetchFromGitHub,
kernel,
kernelModuleMakeFlags,
nvidia_x11,
hash,
patches ? [ ],
broken ? false,
}:
stdenv.mkDerivation (
{
pname = "nvidia-open";
version = "${kernel.version}-${nvidia_x11.version}";
src = fetchFromGitHub {
owner = "NVIDIA";
repo = "open-gpu-kernel-modules";
rev = nvidia_x11.version;
inherit hash;
};
inherit patches;
nativeBuildInputs = kernel.moduleBuildDependencies;
makeFlags =
kernelModuleMakeFlags
++ [
"IGNORE_PREEMPT_RT_PRESENCE=1"
"SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
"SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
"MODLIB=$(out)/lib/modules/${kernel.modDirVersion}"
"DATE="
"TARGET_ARCH=${stdenv.hostPlatform.parsed.cpu.name}"
]
++ lib.optionals stdenv.cc.isClang [
"C_INCLUDE_PATH=${lib.getLib stdenv.cc.cc}/lib/clang/${lib.versions.major stdenv.cc.cc.version}/include"
];
installTargets = [ "modules_install" ];
enableParallelBuilding = true;
meta = with lib; {
description = "NVIDIA Linux Open GPU Kernel Module";
homepage = "https://github.com/NVIDIA/open-gpu-kernel-modules";
license = with licenses; [
gpl2Plus
mit
];
platforms = [
"x86_64-linux"
"aarch64-linux"
];
maintainers = with maintainers; [ nickcao ];
inherit broken;
};
}
// lib.optionalAttrs stdenv.hostPlatform.isAarch64 {
env.NIX_CFLAGS_COMPILE = "-fno-stack-protector";
}
)

View File

@@ -0,0 +1,62 @@
nvidia_x11: sha256:
{
stdenv,
lib,
fetchFromGitHub,
m4,
glibc,
libtirpc,
pkg-config,
}:
stdenv.mkDerivation {
pname = "nvidia-persistenced";
version = nvidia_x11.persistencedVersion;
src = fetchFromGitHub {
owner = "NVIDIA";
repo = "nvidia-persistenced";
rev = nvidia_x11.persistencedVersion;
inherit sha256;
};
env = {
LIBRARY_PATH = "${glibc}/lib";
NIX_CFLAGS_COMPILE = toString [ "-I${libtirpc.dev}/include/tirpc" ];
};
NIX_LDFLAGS = [ "-ltirpc" ];
nativeBuildInputs = [
m4
pkg-config
];
buildInputs = [
libtirpc
stdenv.cc.cc.lib
];
makeFlags = nvidia_x11.makeFlags ++ [ "DATE=true" ];
installFlags = [ "PREFIX=$(out)" ];
postFixup = ''
# Save a copy of persistenced for mounting in containers
mkdir $out/origBin
cp $out/{bin,origBin}/nvidia-persistenced
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 $out/origBin/nvidia-persistenced
patchelf --set-rpath "$(patchelf --print-rpath $out/bin/nvidia-persistenced):${nvidia_x11}/lib" \
$out/bin/nvidia-persistenced
'';
meta = {
homepage = "https://github.com/NVIDIA/nvidia-persistenced";
description = "NVIDIA driver persistence daemon";
license = lib.licenses.mit;
platforms = nvidia_x11.meta.platforms;
maintainers = [ ];
mainProgram = "nvidia-persistenced";
};
}

View File

@@ -0,0 +1,204 @@
nvidia_x11: sha256:
{
stdenv,
lib,
fetchFromGitHub,
fetchpatch,
pkg-config,
m4,
jansson,
gtk2,
dbus,
vulkan-headers,
gtk3,
libXv,
libXrandr,
libXext,
libXxf86vm,
libvdpau,
librsvg,
libglvnd,
wrapGAppsHook3,
addDriverRunpath,
withGtk2 ? false,
withGtk3 ? true,
}:
let
src = fetchFromGitHub {
owner = "NVIDIA";
repo = "nvidia-settings";
rev = nvidia_x11.settingsVersion;
inherit sha256;
};
meta = with lib; {
homepage = "https://www.nvidia.com/object/unix.html";
platforms = nvidia_x11.meta.platforms;
maintainers = with maintainers; [
aidalgol
];
};
libXNVCtrl = stdenv.mkDerivation {
pname = "libXNVCtrl";
version = nvidia_x11.settingsVersion;
inherit src;
buildInputs = [
libXrandr
libXext
];
preBuild = ''
cd src/libXNVCtrl
'';
makeFlags = [
"OUTPUTDIR=." # src/libXNVCtrl
"libXNVCtrl.a"
"libXNVCtrl.so"
];
patches = [
# Patch the Makefile to also produce a shared library.
(
if lib.versionOlder nvidia_x11.settingsVersion "400" then
./libxnvctrl-build-shared-3xx.patch
else
./libxnvctrl-build-shared.patch
)
];
installPhase = ''
mkdir -p $out/lib
mkdir -p $out/include/NVCtrl
cp libXNVCtrl.a $out/lib
cp NVCtrl.h $out/include/NVCtrl
cp NVCtrlLib.h $out/include/NVCtrl
cp -P libXNVCtrl.so* $out/lib
'';
meta = meta // {
description = "NVIDIA NV-CONTROL X extension";
# https://github.com/NVIDIA/nvidia-settings/commit/edcf9edad9f52f9b10e63d4480bbe88b22dde884
license = lib.licenses.mit;
};
};
runtimeDependencies = [
libglvnd
libXrandr
libXv
];
runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies;
in
stdenv.mkDerivation {
pname = "nvidia-settings";
version = nvidia_x11.settingsVersion;
inherit src;
patches =
lib.optional (lib.versionOlder nvidia_x11.settingsVersion "440") (fetchpatch {
# fixes "multiple definition of `VDPAUDeviceFunctions'" linking errors
url = "https://github.com/NVIDIA/nvidia-settings/commit/a7c1f5fce6303a643fadff7d85d59934bd0cf6b6.patch";
hash = "sha256-ZwF3dRTYt/hO8ELg9weoz1U/XcU93qiJL2d1aq1Jlak=";
})
++
lib.optional
(
(lib.versionAtLeast nvidia_x11.settingsVersion "515.43.04")
&& (lib.versionOlder nvidia_x11.settingsVersion "545.29")
)
(fetchpatch {
# fix wayland support for compositors that use wl_output version 4
url = "https://github.com/NVIDIA/nvidia-settings/pull/99/commits/2e0575197e2b3247deafd2a48f45afc038939a06.patch";
hash = "sha256-wKuO5CUTUuwYvsP46Pz+6fI0yxLNpZv8qlbL0TFkEFE=";
});
postPatch = lib.optionalString nvidia_x11.useProfiles ''
sed -i 's,/usr/share/nvidia/,${nvidia_x11.bin}/share/nvidia/,g' src/gtk+-2.x/ctkappprofile.c
'';
enableParallelBuilding = true;
makeFlags = [ "NV_USE_BUNDLED_LIBJANSSON=0" ];
preBuild = ''
if [ -e src/libXNVCtrl/libXNVCtrl.a ]; then
( cd src/libXNVCtrl
make $makeFlags
)
fi
'';
nativeBuildInputs = [
pkg-config
m4
addDriverRunpath
]
++ lib.optionals withGtk3 [ wrapGAppsHook3 ];
buildInputs = [
jansson
libXv
libXrandr
libXext
libXxf86vm
libvdpau
nvidia_x11
dbus
vulkan-headers
]
++ lib.optionals (withGtk2 || lib.versionOlder nvidia_x11.settingsVersion "525.53") [ gtk2 ]
++ lib.optionals withGtk3 [
gtk3
librsvg
];
installFlags = [ "PREFIX=$(out)" ];
postInstall =
lib.optionalString (!withGtk2) ''
rm -f $out/lib/libnvidia-gtk2.so.*
''
+ lib.optionalString (!withGtk3) ''
rm -f $out/lib/libnvidia-gtk3.so.*
''
+ ''
# Install the desktop file and icon.
# The template has substitution variables intended to be replaced resulting
# in absolute paths. Because absolute paths break after the desktop file is
# copied by a desktop environment, make Exec and Icon be just a name.
sed -i doc/nvidia-settings.desktop \
-e "s|^Exec=.*$|Exec=nvidia-settings|" \
-e "s|^Icon=.*$|Icon=nvidia-settings|" \
-e "s|__NVIDIA_SETTINGS_DESKTOP_CATEGORIES__|Settings|g"
install doc/nvidia-settings.desktop -D -t $out/share/applications/
install doc/nvidia-settings.png -D -t $out/share/icons/hicolor/128x128/apps/
'';
binaryName = if withGtk3 then ".nvidia-settings-wrapped" else "nvidia-settings";
postFixup = ''
patchelf --set-rpath "$(patchelf --print-rpath $out/bin/$binaryName):$out/lib:${runtimeLibraryPath}" \
$out/bin/$binaryName
addDriverRunpath $out/bin/$binaryName
'';
passthru = {
inherit libXNVCtrl;
};
meta = meta // {
description = "Settings application for NVIDIA graphics cards";
# nvml.h is licensed as part of the cuda developer license.
license = lib.licenses.unfreeRedistributable;
mainProgram = "nvidia-settings";
};
}