Merge pull request #172660 from NickCao/nvidia-open

nvidia-open: init at 515.43.04
This commit is contained in:
Thiago Kenji Okada 2022-06-17 18:59:32 +01:00 committed by GitHub
commit 4cf04594a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 87 additions and 7 deletions

View file

@ -36,6 +36,18 @@
PHP now defaults to PHP 8.1, updated from 8.0. PHP now defaults to PHP 8.1, updated from 8.0.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
<literal>hardware.nvidia</literal> has a new option
<literal>open</literal> that can be used to opt in the
opensource version of NVIDIA kernel driver. Note that the
drivers support for GeForce and Workstation GPUs is still
alpha quality, see
<link xlink:href="https://developer.nvidia.com/blog/nvidia-releases-open-source-gpu-kernel-modules/">NVIDIA
Releases Open-Source GPU Kernel Modules</link> for the
official announcement.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</section> </section>
<section xml:id="sec-release-22.11-new-services"> <section xml:id="sec-release-22.11-new-services">

View file

@ -19,6 +19,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- PHP now defaults to PHP 8.1, updated from 8.0. - PHP now defaults to PHP 8.1, updated from 8.0.
- `hardware.nvidia` has a new option `open` that can be used to opt in the opensource version of NVIDIA kernel driver. Note that the driver's support for GeForce and Workstation GPUs is still alpha quality, see [NVIDIA Releases Open-Source GPU Kernel Modules](https://developer.nvidia.com/blog/nvidia-releases-open-source-gpu-kernel-modules/) for the official announcement.
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. --> <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
## New Services {#sec-release-22.11-new-services} ## New Services {#sec-release-22.11-new-services}

View file

@ -183,6 +183,14 @@ in
''; '';
example = literalExpression "config.boot.kernelPackages.nvidiaPackages.legacy_340"; example = literalExpression "config.boot.kernelPackages.nvidiaPackages.legacy_340";
}; };
hardware.nvidia.open = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to use the open source kernel module
'';
};
}; };
config = let config = let
@ -231,6 +239,11 @@ in
); );
message = "Required files for driver based power management don't exist."; message = "Required files for driver based power management don't exist.";
} }
{
assertion = cfg.open -> (cfg.package ? open && cfg.package ? firmware);
message = "This version of NVIDIA driver does not provide a corresponding opensource kernel driver";
}
]; ];
# If Optimus/PRIME is enabled, we: # If Optimus/PRIME is enabled, we:
@ -364,7 +377,8 @@ in
++ optional (nvidia_x11.persistenced != null && config.virtualisation.docker.enableNvidia) ++ optional (nvidia_x11.persistenced != null && config.virtualisation.docker.enableNvidia)
"L+ /run/nvidia-docker/extras/bin/nvidia-persistenced - - - - ${nvidia_x11.persistenced}/origBin/nvidia-persistenced"; "L+ /run/nvidia-docker/extras/bin/nvidia-persistenced - - - - ${nvidia_x11.persistenced}/origBin/nvidia-persistenced";
boot.extraModulePackages = [ nvidia_x11.bin ]; boot.extraModulePackages = if cfg.open then [ nvidia_x11.open ] else [ nvidia_x11.bin ];
hardware.firmware = lib.optional cfg.open nvidia_x11.firmware;
# nvidia-uvm is required by CUDA applications. # nvidia-uvm is required by CUDA applications.
boot.kernelModules = [ "nvidia-uvm" ] ++ boot.kernelModules = [ "nvidia-uvm" ] ++
@ -372,7 +386,8 @@ in
# If requested enable modesetting via kernel parameter. # If requested enable modesetting via kernel parameter.
boot.kernelParams = optional (offloadCfg.enable || cfg.modesetting.enable) "nvidia-drm.modeset=1" boot.kernelParams = optional (offloadCfg.enable || cfg.modesetting.enable) "nvidia-drm.modeset=1"
++ optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1"; ++ optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
++ optional cfg.open "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1";
services.udev.extraRules = services.udev.extraRules =
'' ''

View file

@ -147,6 +147,11 @@ installPhase() {
fi fi
fi fi
if [ -n "$firmware" ]; then
# Install the GSP firmware
install -Dm644 firmware/gsp.bin $firmware/lib/firmware/nvidia/$version/gsp.bin
fi
# All libs except GUI-only are installed now, so fixup them. # 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.*') for libname in $(find "$out/lib/" $(test -n "$lib32" && echo "$lib32/lib/") $(test -n "$bin" && echo "$bin/lib/") -name '*.so.*')
do do

View file

@ -3,9 +3,7 @@
let let
generic = args: let generic = args: let
imported = import ./generic.nix args; imported = import ./generic.nix args;
in if lib.versionAtLeast args.version "391" in callPackage imported {
&& stdenv.hostPlatform.system != "x86_64-linux" then null
else callPackage imported {
lib32 = (pkgsi686Linux.callPackage imported { lib32 = (pkgsi686Linux.callPackage imported {
libsOnly = true; libsOnly = true;
kernel = null; kernel = null;
@ -21,6 +19,7 @@ rec {
then generic { then generic {
version = "515.48.07"; version = "515.48.07";
sha256_64bit = "sha256-4odkzFsTwy52NwUT2ur8BcKJt37gURVSRQ8aAOMa4eM="; sha256_64bit = "sha256-4odkzFsTwy52NwUT2ur8BcKJt37gURVSRQ8aAOMa4eM=";
openSha256 = "sha256-EGIrdabPr+AhQxXhFb8XXumuPxC+U6XEeIeSYFvA/q4=";
settingsSha256 = "sha256-XwdMsAAu5132x2ZHqjtFvcBJk6Dao7I86UksxrOkknU="; settingsSha256 = "sha256-XwdMsAAu5132x2ZHqjtFvcBJk6Dao7I86UksxrOkknU=";
persistencedSha256 = "sha256-BTfYNDJKe4tOvV71/1JJSPltJua0Mx/RvDcWT5ccRRY="; persistencedSha256 = "sha256-BTfYNDJKe4tOvV71/1JJSPltJua0Mx/RvDcWT5ccRRY=";
} }
@ -32,6 +31,7 @@ rec {
beta = generic { beta = generic {
version = "515.43.04"; version = "515.43.04";
sha256_64bit = "sha256-PodaTTUOSyMW8rtdtabIkSLskgzAymQyfToNlwxPPcc="; sha256_64bit = "sha256-PodaTTUOSyMW8rtdtabIkSLskgzAymQyfToNlwxPPcc=";
openSha256 = "sha256-1bAr5dWZ4jnY3Uo2JaEz/rhw2HuW9LZ5bACmA1VG068=";
settingsSha256 = "sha256-j47LtP6FNTPfiXFh9KwXX8vZOQzlytA30ZfW9N5F2PY="; settingsSha256 = "sha256-j47LtP6FNTPfiXFh9KwXX8vZOQzlytA30ZfW9N5F2PY=";
persistencedSha256 = "sha256-hULBy0wnVpLH8I0L6O9/HfgvJURtE2whpXOgN/vb3Wo="; persistencedSha256 = "sha256-hULBy0wnVpLH8I0L6O9/HfgvJURtE2whpXOgN/vb3Wo=";
}; };
@ -46,6 +46,7 @@ rec {
settingsSha256 = "sha256-fq6RlD6g3uylvvTjE4MmaQwxPJYU0u6IMfpPVzks0tI="; settingsSha256 = "sha256-fq6RlD6g3uylvvTjE4MmaQwxPJYU0u6IMfpPVzks0tI=";
persistencedSha256 = "sha256-eHvauvh8Wd+b8DK6B3ZWNjoWGztupWrR8iog9ok58io="; persistencedSha256 = "sha256-eHvauvh8Wd+b8DK6B3ZWNjoWGztupWrR8iog9ok58io=";
url = "https://developer.nvidia.com/vulkan-beta-${lib.concatStrings (lib.splitString "." version)}-linux"; url = "https://developer.nvidia.com/vulkan-beta-${lib.concatStrings (lib.splitString "." version)}-linux";
broken = kernel.kernelAtLeast "5.17";
}; };
# Update note: # Update note:

View file

@ -2,6 +2,7 @@
, url ? null , url ? null
, sha256_32bit ? null , sha256_32bit ? null
, sha256_64bit , sha256_64bit
, openSha256 ? null
, settingsSha256 , settingsSha256
, settingsVersion ? version , settingsVersion ? version
, persistencedSha256 , persistencedSha256
@ -27,13 +28,14 @@
disable32Bit ? false disable32Bit ? false
# 32 bit libs only version of this package # 32 bit libs only version of this package
, lib32 ? null , lib32 ? null
# Whether to extract the GSP firmware
, firmware ? openSha256 != null
}: }:
with lib; with lib;
assert !libsOnly -> kernel != null; assert !libsOnly -> kernel != null;
assert versionOlder version "391" -> sha256_32bit != null; assert versionOlder version "391" -> sha256_32bit != null;
assert versionAtLeast version "391" -> stdenv.hostPlatform.system == "x86_64-linux";
let let
nameSuffix = optionalString (!libsOnly) "-${kernel.version}"; nameSuffix = optionalString (!libsOnly) "-${kernel.version}";
@ -72,7 +74,8 @@ let
outputs = [ "out" ] outputs = [ "out" ]
++ optional i686bundled "lib32" ++ optional i686bundled "lib32"
++ optional (!libsOnly) "bin"; ++ optional (!libsOnly) "bin"
++ optional (!libsOnly && firmware) "firmware";
outputDev = if libsOnly then null else "bin"; outputDev = if libsOnly then null else "bin";
kernel = if libsOnly then null else kernel.dev; kernel = if libsOnly then null else kernel.dev;
@ -100,6 +103,7 @@ let
disallowedReferences = optional (!libsOnly) [ kernel.dev ]; disallowedReferences = optional (!libsOnly) [ kernel.dev ];
passthru = { passthru = {
open = mapNullable (hash: callPackage (import ./open.nix self hash) { }) openSha256;
settings = (if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256) { settings = (if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256) {
withGtk2 = preferGtk2; withGtk2 = preferGtk2;
withGtk3 = !preferGtk2; withGtk3 = !preferGtk2;

View file

@ -0,0 +1,37 @@
nvidia_x11: hash:
{ stdenv
, lib
, fetchFromGitHub
, kernel
}:
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;
};
nativeBuildInputs = kernel.moduleBuildDependencies;
makeFlags = kernel.makeFlags ++ [
"SYSSRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/source"
"SYSOUT=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
"MODLIB=$(out)/lib/modules/${kernel.modDirVersion}"
];
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 = platforms.linux;
maintainers = with maintainers; [ nickcao ];
};
}

View file

@ -357,6 +357,10 @@ in {
nvidia_x11_vulkan_beta = nvidiaPackages.vulkan_beta; nvidia_x11_vulkan_beta = nvidiaPackages.vulkan_beta;
nvidia_x11 = nvidiaPackages.stable; nvidia_x11 = nvidiaPackages.stable;
# this is not a replacement for nvidia_x11
# only the opensource kernel driver exposed for hydra to build
nvidia_x11_beta_open = nvidiaPackages.beta.open;
openrazer = callPackage ../os-specific/linux/openrazer/driver.nix { }; openrazer = callPackage ../os-specific/linux/openrazer/driver.nix { };
ply = callPackage ../os-specific/linux/ply { }; ply = callPackage ../os-specific/linux/ply { };