From c52bcc4591e28b1fc1df955470d46b71ce3a86bd Mon Sep 17 00:00:00 2001 From: Aietes Date: Tue, 11 Mar 2025 11:19:05 +0100 Subject: [PATCH 1/6] feat: option to get driver from rpm from NVIDIA RHEL repository --- nixGL.nix | 65 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/nixGL.nix b/nixGL.nix index e8556c8..9ab3a7d 100644 --- a/nixGL.nix +++ b/nixGL.nix @@ -9,6 +9,9 @@ nvidiaHash ? null, # /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see # https://github.com/NixOS/nix/issues/3539 ). nvidiaVersionFile ? null, +# Nvidia driver source selection: "driver" (default) which will attempt to download .run file from NVIDIA's driver site +# or "rhel", which downloads the RPM packages from NVIDIA's RHEL repository, ensuring a version match in RHEL systems like Rocky Linux, Fedora or CentOS. +driverSource ? "driver", # Enable 32 bits driver # This is one by default, you can switch it to off if you want to reduce a # bit the size of nixGL closure. @@ -16,7 +19,7 @@ enable32bits ? stdenv.hostPlatform.isx86 , stdenv, writeTextFile, shellcheck, pcre, runCommand, linuxPackages , fetchurl, lib, runtimeShell, bumblebee, libglvnd, vulkan-validation-layers , mesa, libvdpau-va-gl, intel-media-driver, pkgsi686Linux, driversi686Linux -, zlib, libdrm, xorg, wayland, gcc, zstd }: +, zlib, libdrm, xorg, wayland, gcc, zstd, rpm, cpio }: let writeExecutable = { name, text }: @@ -62,13 +65,59 @@ let exec "$@" ''; }; + top = rec { /* It contains the builder for different nvidia configuration, parametrized by the version of the driver and sha256 sum of the driver installer file. */ nvidiaPackages = { version, sha256 ? null }: rec { - nvidiaDrivers = (linuxPackages.nvidia_x11.override { }).overrideAttrs + + # download rpm packages if RHEL is selected as driver source + rpmDriver = if driverSource == "rhel" then + builtins.fetchurl { + url = "https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/nvidia-driver-${version}-1.el9.x86_64.rpm"; + } + else + null; + + rpmLibs = if driverSource == "rhel" then + builtins.fetchurl { + url = "https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/nvidia-driver-libs-${version}-1.el9.x86_64.rpm"; + } + else + null; + + # Extract NVIDIA shared libraries from RPM + nvidiaFromRpm = stdenv.mkDerivation { + pname = "nvidia"; + name = "nvidia-${version}-nixGL-rpm"; + version = version; + preferLocalBuild = true; + allowSubstitutes = false; + nativeBuildInputs = [ rpm cpio ]; + srcs = [ rpmDriver rpmLibs ]; + unpackPhase = '' + mkdir -p $TMPDIR + cp ${rpmLibs} $TMPDIR/nvidia-driver-libs.rpm + cp ${rpmDriver} $TMPDIR/nvidia-driver.rpm + ''; + buildPhase = '' + mkdir -p $out + cd $TMPDIR + + rpm2cpio nvidia-driver-libs.rpm | cpio -idmv + mv usr/lib64 $out/lib + mv usr/share $out/share + + rpm2cpio nvidia-driver.rpm | cpio -idmv + mv usr/bin $out/bin + mv usr/share $out/share + mv usr/lib $out/lib + ''; + }; + + nvidiaDrivers = if driverSource == "driver" then (linuxPackages.nvidia_x11.override { }).overrideAttrs (oldAttrs: rec { pname = "nvidia"; name = "nvidia-x11-${version}-nixGL"; @@ -82,12 +131,14 @@ let builtins.fetchurl url; useGLVND = true; nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [zstd]; - }); + }) + else + null; - nvidiaLibsOnly = nvidiaDrivers.override { - libsOnly = true; - kernel = null; - }; + nvidiaLibsOnly = if driverSource == "driver" then + (nvidiaDrivers.override { libsOnly = true; kernel = null; }) + else + nvidiaFromRpm; nixGLNvidiaBumblebee = writeExecutable { name = "nixGLNvidiaBumblebee-${version}"; From 791d3b1bdd802bd7bbeb69fa3605b570c534871a Mon Sep 17 00:00:00 2001 From: Aietes Date: Tue, 11 Mar 2025 11:24:12 +0100 Subject: [PATCH 2/6] refactor: remove driver RPM, as it's not really needed for nixGL to work --- nixGL.nix | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/nixGL.nix b/nixGL.nix index 9ab3a7d..8cd1d5e 100644 --- a/nixGL.nix +++ b/nixGL.nix @@ -74,13 +74,6 @@ let nvidiaPackages = { version, sha256 ? null }: rec { # download rpm packages if RHEL is selected as driver source - rpmDriver = if driverSource == "rhel" then - builtins.fetchurl { - url = "https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/nvidia-driver-${version}-1.el9.x86_64.rpm"; - } - else - null; - rpmLibs = if driverSource == "rhel" then builtins.fetchurl { url = "https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/nvidia-driver-libs-${version}-1.el9.x86_64.rpm"; @@ -96,11 +89,10 @@ let preferLocalBuild = true; allowSubstitutes = false; nativeBuildInputs = [ rpm cpio ]; - srcs = [ rpmDriver rpmLibs ]; + srcs = [ rpmLibs ]; unpackPhase = '' mkdir -p $TMPDIR cp ${rpmLibs} $TMPDIR/nvidia-driver-libs.rpm - cp ${rpmDriver} $TMPDIR/nvidia-driver.rpm ''; buildPhase = '' mkdir -p $out @@ -109,11 +101,6 @@ let rpm2cpio nvidia-driver-libs.rpm | cpio -idmv mv usr/lib64 $out/lib mv usr/share $out/share - - rpm2cpio nvidia-driver.rpm | cpio -idmv - mv usr/bin $out/bin - mv usr/share $out/share - mv usr/lib $out/lib ''; }; From a459b9192d1020400c7a22cd0aa77963a512a305 Mon Sep 17 00:00:00 2001 From: Aietes Date: Tue, 11 Mar 2025 12:24:49 +0100 Subject: [PATCH 3/6] fix(rhel): add libnvidia-ml as it is required by btop and other apps copy additional rpm to temp in unpack phase --- nixGL.nix | 107 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 42 deletions(-) diff --git a/nixGL.nix b/nixGL.nix index 8cd1d5e..fa6539f 100644 --- a/nixGL.nix +++ b/nixGL.nix @@ -15,11 +15,11 @@ driverSource ? "driver", # Enable 32 bits driver # This is one by default, you can switch it to off if you want to reduce a # bit the size of nixGL closure. -enable32bits ? stdenv.hostPlatform.isx86 -, stdenv, writeTextFile, shellcheck, pcre, runCommand, linuxPackages -, fetchurl, lib, runtimeShell, bumblebee, libglvnd, vulkan-validation-layers -, mesa, libvdpau-va-gl, intel-media-driver, pkgsi686Linux, driversi686Linux -, zlib, libdrm, xorg, wayland, gcc, zstd, rpm, cpio }: +enable32bits ? stdenv.hostPlatform.isx86, stdenv, writeTextFile, shellcheck +, pcre, runCommand, linuxPackages, fetchurl, lib, runtimeShell, bumblebee +, libglvnd, vulkan-validation-layers, mesa, libvdpau-va-gl, intel-media-driver +, pkgsi686Linux, driversi686Linux, zlib, libdrm, xorg, wayland, gcc, zstd, rpm +, cpio }: let writeExecutable = { name, text }: @@ -40,7 +40,8 @@ let ''; }; - writeNixGL = name: vadrivers: writeExecutable { + writeNixGL = name: vadrivers: + writeExecutable { inherit name; # add the 32 bits drivers if needed text = let @@ -54,29 +55,46 @@ let ''); in '' #!${runtimeShell} - export LIBGL_DRIVERS_PATH=${lib.makeSearchPathOutput "lib" "lib/dri" mesa-drivers} - export LIBVA_DRIVERS_PATH=${lib.makeSearchPathOutput "out" "lib/dri" (mesa-drivers ++ vadrivers)} - ${''export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json${ - lib.optionalString enable32bits - ":${pkgsi686Linux.mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json" - }"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"'' + export LIBGL_DRIVERS_PATH=${ + lib.makeSearchPathOutput "lib" "lib/dri" mesa-drivers } - export LD_LIBRARY_PATH=${lib.makeLibraryPath mesa-drivers}:${lib.makeSearchPathOutput "lib" "lib/vdpau" libvdpau}:${glxindirect}/lib:${lib.makeLibraryPath [libglvnd]}"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + export LIBVA_DRIVERS_PATH=${ + lib.makeSearchPathOutput "out" "lib/dri" (mesa-drivers ++ vadrivers) + } + ${'' + export __EGL_VENDOR_LIBRARY_FILENAMES=${mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json${ + lib.optionalString enable32bits + ":${pkgsi686Linux.mesa.drivers}/share/glvnd/egl_vendor.d/50_mesa.json" + }"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"''} + export LD_LIBRARY_PATH=${lib.makeLibraryPath mesa-drivers}:${ + lib.makeSearchPathOutput "lib" "lib/vdpau" libvdpau + }:${glxindirect}/lib:${ + lib.makeLibraryPath [ libglvnd ] + }"''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" exec "$@" ''; }; top = rec { - /* - It contains the builder for different nvidia configuration, parametrized by - the version of the driver and sha256 sum of the driver installer file. + /* It contains the builder for different nvidia configuration, parametrized by + the version of the driver and sha256 sum of the driver installer file. */ nvidiaPackages = { version, sha256 ? null }: rec { # download rpm packages if RHEL is selected as driver source rpmLibs = if driverSource == "rhel" then builtins.fetchurl { - url = "https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/nvidia-driver-libs-${version}-1.el9.x86_64.rpm"; + url = + "https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/nvidia-driver-libs-${version}-1.el9.x86_64.rpm"; + } + else + null; + + # also get the ml library if RHEL is selected as driver source, required by btop and other tools + rpmMl = if driverSource == "rhel" then + builtins.fetchurl { + url = + "https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/libnvidia-ml-${version}-1.el9.x86_64.rpm"; } else null; @@ -89,23 +107,27 @@ let preferLocalBuild = true; allowSubstitutes = false; nativeBuildInputs = [ rpm cpio ]; - srcs = [ rpmLibs ]; + srcs = [ rpmLibs rpmMl ]; unpackPhase = '' mkdir -p $TMPDIR cp ${rpmLibs} $TMPDIR/nvidia-driver-libs.rpm + cp ${rpmMl} $TMPDIR/libnvidia-ml.rpm ''; buildPhase = '' - mkdir -p $out + mkdir -p $out $out/lib $out/share cd $TMPDIR rpm2cpio nvidia-driver-libs.rpm | cpio -idmv - mv usr/lib64 $out/lib - mv usr/share $out/share + mv usr/lib64/* $out/lib + mv usr/share/* $out/share + + rpm2cpio libnvidia-ml.rpm | cpio -idmv + mv usr/lib64/* $out/lib ''; }; - nvidiaDrivers = if driverSource == "driver" then (linuxPackages.nvidia_x11.override { }).overrideAttrs - (oldAttrs: rec { + nvidiaDrivers = if driverSource == "driver" then + (linuxPackages.nvidia_x11.override { }).overrideAttrs (oldAttrs: rec { pname = "nvidia"; name = "nvidia-x11-${version}-nixGL"; inherit version; @@ -117,13 +139,16 @@ let else builtins.fetchurl url; useGLVND = true; - nativeBuildInputs = oldAttrs.nativeBuildInputs or [] ++ [zstd]; + nativeBuildInputs = oldAttrs.nativeBuildInputs or [ ] ++ [ zstd ]; }) else null; nvidiaLibsOnly = if driverSource == "driver" then - (nvidiaDrivers.override { libsOnly = true; kernel = null; }) + (nvidiaDrivers.override { + libsOnly = true; + kernel = null; + }) else nvidiaFromRpm; @@ -158,20 +183,20 @@ let ${lib.optionalString (api == "Vulkan") "export VK_LAYER_PATH=${vulkan-validation-layers}/share/vulkan/explicit_layer.d"} NVIDIA_JSON=(${nvidiaLibsOnly}/share/glvnd/egl_vendor.d/*nvidia.json) - ${lib.optionalString enable32bits "NVIDIA_JSON32=(${nvidiaLibsOnly.lib32}/share/glvnd/egl_vendor.d/*nvidia.json)"} + ${lib.optionalString enable32bits + "NVIDIA_JSON32=(${nvidiaLibsOnly.lib32}/share/glvnd/egl_vendor.d/*nvidia.json)"} - ${''export __EGL_VENDOR_LIBRARY_FILENAMES=''${NVIDIA_JSON[*]}${ - lib.optionalString enable32bits - '':''${NVIDIA_JSON32[*]}'' - }"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"'' - } + ${'' + export __EGL_VENDOR_LIBRARY_FILENAMES=''${NVIDIA_JSON[*]}${ + lib.optionalString enable32bits ":\${NVIDIA_JSON32[*]}" + }"''${__EGL_VENDOR_LIBRARY_FILENAMES:+:$__EGL_VENDOR_LIBRARY_FILENAMES}"''} ${ - lib.optionalString (api == "Vulkan") - ''export VK_ICD_FILENAMES=${nvidiaLibsOnly}/share/vulkan/icd.d/nvidia_icd.x86_64.json${ - lib.optionalString enable32bits - ":${nvidiaLibsOnly.lib32}/share/vulkan/icd.d/nvidia_icd.i686.json" - }"''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}"'' + lib.optionalString (api == "Vulkan") '' + export VK_ICD_FILENAMES=${nvidiaLibsOnly}/share/vulkan/icd.d/nvidia_icd.x86_64.json${ + lib.optionalString enable32bits + ":${nvidiaLibsOnly.lib32}/share/vulkan/icd.d/nvidia_icd.i686.json" + }"''${VK_ICD_FILENAMES:+:$VK_ICD_FILENAMES}"'' } export LD_LIBRARY_PATH=${ lib.makeLibraryPath ([ libglvnd nvidiaLibsOnly ] @@ -192,12 +217,10 @@ let nixVulkanNvidia = nixNvidiaWrapper "Vulkan"; }; + nixGLMesa = writeNixGL "nixGLMesa" [ ]; - nixGLMesa = writeNixGL "nixGLMesa" [ ]; - - nixGLIntel = writeNixGL "nixGLIntel" - ([ intel-media-driver ] - ++ lib.optionals enable32bits [ pkgsi686Linux.intel-media-driver ]); + nixGLIntel = writeNixGL "nixGLIntel" ([ intel-media-driver ] + ++ lib.optionals enable32bits [ pkgsi686Linux.intel-media-driver ]); nixVulkanMesa = writeExecutable { name = "nixVulkanIntel"; @@ -274,7 +297,7 @@ let versionMatch = builtins.match ".*Module ([0-9.]+) .*" data; in if versionMatch != null then builtins.head versionMatch else null; - autoNvidia = nvidiaPackages {version = nvidiaVersionAuto; }; + autoNvidia = nvidiaPackages { version = nvidiaVersionAuto; }; in rec { # The output derivation contains nixGL which point either to # nixGLNvidia or nixGLIntel using an heuristic. From bbfec7f85e28c3033f03477a9cda0879a050f390 Mon Sep 17 00:00:00 2001 From: Aietes Date: Tue, 11 Mar 2025 13:22:26 +0100 Subject: [PATCH 4/6] fix(rhel): make rhel the condition instead of driver --- nixGL.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nixGL.nix b/nixGL.nix index fa6539f..be2d521 100644 --- a/nixGL.nix +++ b/nixGL.nix @@ -126,7 +126,9 @@ let ''; }; - nvidiaDrivers = if driverSource == "driver" then + nvidiaDrivers = if driverSource == "rhel" then + null + else (linuxPackages.nvidia_x11.override { }).overrideAttrs (oldAttrs: rec { pname = "nvidia"; name = "nvidia-x11-${version}-nixGL"; @@ -140,17 +142,15 @@ let builtins.fetchurl url; useGLVND = true; nativeBuildInputs = oldAttrs.nativeBuildInputs or [ ] ++ [ zstd ]; - }) - else - null; + }); - nvidiaLibsOnly = if driverSource == "driver" then + nvidiaLibsOnly = if driverSource == "rhel" then + nvidiaFromRpm + else (nvidiaDrivers.override { libsOnly = true; kernel = null; - }) - else - nvidiaFromRpm; + }); nixGLNvidiaBumblebee = writeExecutable { name = "nixGLNvidiaBumblebee-${version}"; From 88b0013d4c53854bc64b5c28a6a857cc2a3aa086 Mon Sep 17 00:00:00 2001 From: Aietes Date: Tue, 11 Mar 2025 15:25:52 +0100 Subject: [PATCH 5/6] docs(readme): update README with instruction to get driver from RHEL repository --- README.md | 59 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 79d05b4..9c5f8b7 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ libGL error: failed to load driver: swrast NixGL provides a set of wrappers able to launch GL or Vulkan applications: ```bash -$ nixGL program -$ nixVulkan program +nixGL program +nixVulkan program ``` # Installation @@ -32,8 +32,8 @@ $ nixVulkan program To get started, ```bash -$ nix-channel --add https://github.com/nix-community/nixGL/archive/main.tar.gz nixgl && nix-channel --update -$ nix-env -iA nixgl.auto.nixGLDefault # or replace `nixGLDefault` with your desired wrapper +nix-channel --add https://github.com/nix-community/nixGL/archive/main.tar.gz nixgl && nix-channel --update +nix-env -iA nixgl.auto.nixGLDefault # or replace `nixGLDefault` with your desired wrapper ``` Many wrappers are available, depending on your hardware and the graphical API you want to use (i.e. Vulkan or OpenGL). You may want to install a few of them, for example if you want to support OpenGL and Vulkan on a laptop with an hybrid configuration. @@ -84,7 +84,6 @@ nix profile install github:guibou/nixGL --impure This will result in a lighter download and execution time. Also, this evaluation is pure. - #### Error about experimental features You can directly use: @@ -98,6 +97,7 @@ Or set the appropriate conf in `~/.config/nix/nix.conf` / `/etc/nix/nix.conf` / #### Error with GLIBC version if you get errors with messages similar to + ``` /nix/store/g02b1lpbddhymmcjb923kf0l7s9nww58-glibc-2.33-123/lib/libc.so.6: version `GLIBC_2.34' not found (required by /nix/store/hrl51nkr7dszlwcs29wmyxq0jsqlaszn-libglvnd-1.4.0/lib/libGLX.so.0) ``` @@ -108,7 +108,6 @@ It means that there's a mismatch between the versions of `nixpkgs` used by `nixG Add nixGL as a flake input: - ```Nix { inputs = { @@ -134,12 +133,39 @@ Then, use the flake's `overlay` attr: } ``` +### Install from RHEL repository (Rocky, CentOS, Fedora, etc.) + +On RHEL the NVIDIA driver is typically installed via the official NVIDIA driver repositories. Trying to install the driver from the download site will commonly fail with a 404 error. This is due to the fact that NVIDIA is not providing consistent versions of their drivers across distribution channels, so you might have a driver version installed on your system that is not available on the download site. Therefore on RHEL distros the driver should be retrieved from the RHEL repository, and extracted from an official `.rpm`. + +To get the driver from the RHEL `.rpm` instead of the driver download site, simply set `driverSource` to `rhel`. Also ensure that `enable32bits` is changed from its default to `false`, as a 32bit version of the driver is not included. Here's an example flake using +the nixGL overlay with `home-manager`: + +```nix +{ + home.packages = with pkgs; [ + (nixgl.override { + driverSource = "rhel"; + enable32bits = false; + }).auto.nixGLDefault + (config.lib.nixGL.wrap ghostty) + ]; + + nixGL = { + packages = pkgs.nixgl.override { + driverSource = "rhel"; + enable32bits = false; + }; + defaultWrapper = "nvidia"; + }; +}; +``` + ## Installation from source ```bash -$ git clone https://github.com/nix-community/nixGL -$ cd nixGL -$ nix-env -f ./ -iA +git clone https://github.com/nix-community/nixGL +cd nixGL +nix-env -f ./ -iA ``` # Usage @@ -149,17 +175,17 @@ Just launch the program you want prefixed by the right wrapper. For example, for OpenGL programs: ```bash -$ nixGL program args # For the `nixGLDefault` wrapper, recommended. -$ nixGLNvidia program args -$ nixGLIntel program args -$ nixGLNvidiaBumblebee program args +nixGL program args # For the `nixGLDefault` wrapper, recommended. +nixGLNvidia program args +nixGLIntel program args +nixGLNvidiaBumblebee program args ``` For Vulkan programs: ```bash -$ nixVulkanNvidia program args -$ nixVulkanIntel program args +nixVulkanNvidia program args +nixVulkanIntel program args ``` # OpenGL - Hybrid Intel + Nvidia laptop @@ -176,7 +202,7 @@ OpenGL version string: 4.6.0 NVIDIA 390.25 If the program you'd like to run is already installed by nix in your current environment, you can simply run it with the wrapper, for example: ```bash -$ nixGLIntel blender +nixGLIntel blender ``` # Vulkan - Intel GPU @@ -216,7 +242,6 @@ nix-build -A auto.nixGLNvidia --argstr nvidiaVersion 440.82 (or `nixGLNvidiaBumblebee`, `nixVulkanNividia`) - The version of your driver can be found using `glxinfo` from your system default package manager, or `nvidia-settings`. ## On nixOS From 54dfd4d799ae07bd38da3566adeb10f0b2ba9f07 Mon Sep 17 00:00:00 2001 From: Aietes Date: Wed, 17 Sep 2025 17:53:32 +0200 Subject: [PATCH 6/6] fix(rhel): support rhel major version option --- README.md | 1 + nixGL.nix | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9c5f8b7..ef83e02 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ the nixGL overlay with `home-manager`: packages = pkgs.nixgl.override { driverSource = "rhel"; enable32bits = false; + rhelMajorVersion = 10; }; defaultWrapper = "nvidia"; }; diff --git a/nixGL.nix b/nixGL.nix index be2d521..0ff8b35 100644 --- a/nixGL.nix +++ b/nixGL.nix @@ -9,9 +9,10 @@ nvidiaHash ? null, # /proc/driver/nvidia/version. Nix doesn't like zero-sized files (see # https://github.com/NixOS/nix/issues/3539 ). nvidiaVersionFile ? null, -# Nvidia driver source selection: "driver" (default) which will attempt to download .run file from NVIDIA's driver site -# or "rhel", which downloads the RPM packages from NVIDIA's RHEL repository, ensuring a version match in RHEL systems like Rocky Linux, Fedora or CentOS. +# Nvidia driver source selection: "driver" (default) or "rhel" (downloads RPMs from NVIDIA's RHEL repo) driverSource ? "driver", +# RHEL major version (e.g., 9 or 10) for NVIDIA RPM URLs. User must set this if using driverSource = "rhel" +rhelMajorVersion ? 10, # Enable 32 bits driver # This is one by default, you can switch it to off if you want to reduce a # bit the size of nixGL closure. @@ -85,7 +86,7 @@ let rpmLibs = if driverSource == "rhel" then builtins.fetchurl { url = - "https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/nvidia-driver-libs-${version}-1.el9.x86_64.rpm"; + "https://developer.download.nvidia.com/compute/cuda/repos/rhel${toString rhelMajorVersion}/x86_64/nvidia-driver-libs-${version}-1.el${toString rhelMajorVersion}.x86_64.rpm"; } else null; @@ -94,7 +95,7 @@ let rpmMl = if driverSource == "rhel" then builtins.fetchurl { url = - "https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/libnvidia-ml-${version}-1.el9.x86_64.rpm"; + "https://developer.download.nvidia.com/compute/cuda/repos/rhel${toString rhelMajorVersion}/x86_64/libnvidia-ml-${version}-1.el${toString rhelMajorVersion}.x86_64.rpm"; } else null;