Loading nixos/modules/hardware/video/nvidia.nix +36 −26 Original line number Diff line number Diff line Loading @@ -92,7 +92,8 @@ in information, see the NVIDIA docs, on Chapter 23. Dynamic Boost on Linux ''; modesetting.enable = lib.mkEnableOption '' modesetting.enable = lib.mkEnableOption '' kernel modesetting when using the NVIDIA proprietary driver. Enabling this fixes screen tearing when using Optimus via PRIME (see Loading @@ -103,7 +104,8 @@ in Enabling this and using version 545 or newer of the proprietary NVIDIA driver causes it to provide its own framebuffer device, which can cause Wayland compositors to work when they otherwise wouldn't. '' // { '' // { default = lib.versionAtLeast cfg.package.version "535"; defaultText = lib.literalExpression "lib.versionAtLeast cfg.package.version \"535\""; }; Loading Loading @@ -266,9 +268,11 @@ in ''; }; gsp.enable = lib.mkEnableOption '' gsp.enable = lib.mkEnableOption '' the GPU System Processor (GSP) on the video card '' // { '' // { default = useOpenModules || lib.versionAtLeast nvidia_x11.version "555"; defaultText = lib.literalExpression '' config.hardware.nvidia.open == true || lib.versionAtLeast config.hardware.nvidia.package.version "555" Loading Loading @@ -323,7 +327,9 @@ in softdep nvidia post: nvidia-uvm ''; }; systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [ "L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin" ]; systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [ "L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin" ]; services.udev.extraRules = '' # Create /dev/nvidia-uvm when the nvidia-uvm module is loaded. KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c 195 255'" Loading Loading @@ -622,7 +628,9 @@ in # If requested enable modesetting via kernel parameters. kernelParams = lib.optional (offloadCfg.enable || cfg.modesetting.enable) "nvidia-drm.modeset=1" ++ lib.optional ((offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545") "nvidia-drm.fbdev=1" ++ lib.optional ( (offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545" ) "nvidia-drm.fbdev=1" ++ lib.optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1" ++ lib.optional useOpenModules "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1" ++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off"; Loading Loading @@ -683,7 +691,9 @@ in TOPOLOGY_FILE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch"; DATABASE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch"; }; nv-fab-conf = settingsFormat.generate "fabricmanager.conf" (fabricManagerConfDefaults // cfg.datacenter.settings); nv-fab-conf = settingsFormat.generate "fabricmanager.conf" ( fabricManagerConfDefaults // cfg.datacenter.settings ); in "${lib.getExe nvidia_x11.fabricmanager} -c ${nv-fab-conf}"; LimitCORE = "infinity"; Loading pkgs/os-specific/linux/nvidia-x11/default.nix +114 −93 Original line number Diff line number Diff line { lib, callPackage, fetchFromGitHub, fetchgit, fetchpatch, stdenv, pkgsi686Linux }: { lib, callPackage, fetchFromGitHub, fetchgit, fetchpatch, stdenv, pkgsi686Linux, }: let generic = args: let generic = args: let imported = import ./generic.nix args; in callPackage imported { lib32 = (pkgsi686Linux.callPackage imported { in callPackage imported { lib32 = (pkgsi686Linux.callPackage imported { libsOnly = true; kernel = null; }).out; }; kernel = callPackage # a hacky way of extracting parameters from callPackage ({ kernel, libsOnly ? false }: if libsOnly then { } else kernel) { }; 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; 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 { Loading Loading @@ -136,7 +153,8 @@ rec { }; # Last one supporting x86 legacy_390 = let legacy_390 = let # Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms aurPatches = fetchgit { url = "https://aur.archlinux.org/nvidia-390xx-utils.git"; Loading @@ -154,7 +172,8 @@ rec { "gcc-14.patch" "kernel-6.10.patch" ]; in generic { in generic { version = "390.157"; sha256_32bit = "sha256-VdZeCkU5qct5YgDF8Qgv4mP7CVHeqvlqnP/rioD3B5k="; sha256_64bit = "sha256-W+u8puj+1da52BBw+541HxjtxTSVJVPL3HHo/QubMoo="; Loading @@ -173,7 +192,8 @@ rec { ''; }; legacy_340 = let legacy_340 = let # Source corresponding to https://aur.archlinux.org/packages/nvidia-340xx-dkms aurPatches = fetchFromGitHub { owner = "archlinux-jerry"; Loading @@ -198,7 +218,8 @@ rec { "0014-kernel-6.5.patch" "0015-kernel-6.6.patch" ]; in generic { in generic { version = "340.108"; sha256_32bit = "1jkwa1phf0x4sgw8pvr9d6krmmr3wkgwyygrxhdazwyr2bbalci0"; sha256_64bit = "06xp6c0sa7v1b82gf0pq0i5p0vdhmm3v964v0ypw36y0nzqx8wf6"; Loading pkgs/os-specific/linux/nvidia-x11/generic.nix +188 −131 Original line number Diff line number Diff line { version , url ? null , sha256_32bit ? null , sha256_64bit , sha256_aarch64 ? null , openSha256 ? null , settingsSha256 ? null , settingsVersion ? version , persistencedSha256 ? null , persistencedVersion ? version , fabricmanagerSha256 ? null , fabricmanagerVersion ? version , useGLVND ? true , useProfiles ? true , preferGtk2 ? false , settings32Bit ? false , useSettings ? true , usePersistenced ? true , useFabricmanager ? false , ibtSupport ? false { version, url ? null, sha256_32bit ? null, sha256_64bit, sha256_aarch64 ? null, openSha256 ? null, settingsSha256 ? null, settingsVersion ? version, persistencedSha256 ? null, persistencedVersion ? version, fabricmanagerSha256 ? null, fabricmanagerVersion ? version, 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 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 , perl , nukeReferences , which , libarchive , jq , # Whether to build the libraries only (i.e. not the kernel module or { lib, stdenv, runCommandLocal, patchutils, callPackage, pkgs, pkgsi686Linux, fetchurl, fetchzip, kernel ? null, 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, libsOnly ? false, # don't include the bundled 32-bit libraries on 64-bit platforms, # even if it’s in downloaded binary disable32Bit ? stdenv.hostPlatform.system == "aarch64-linux" disable32Bit ? stdenv.hostPlatform.system == "aarch64-linux", # 32 bit libs only version of this package , lib32 ? null lib32 ? null, # Whether to extract the GSP firmware, datacenter drivers needs to extract the # firmware , firmware ? openSha256 != null || useFabricmanager firmware ? openSha256 != null || useFabricmanager, # Whether the user accepts the NVIDIA Software License , config , acceptLicense ? config.nvidia.acceptLicense or false config, acceptLicense ? config.nvidia.acceptLicense or false, }: assert !libsOnly -> kernel != null; Loading Loading @@ -97,7 +99,11 @@ let pkgSuffix = lib.optionalString (lib.versionOlder version "304") "-pkg0"; i686bundled = lib.versionAtLeast version "391" && !disable32Bit; libPathFor = pkgs: lib.makeLibraryPath (with pkgs; [ libPathFor = pkgs: lib.makeLibraryPath ( with pkgs; [ libdrm xorg.libXext xorg.libX11 Loading @@ -111,7 +117,8 @@ let libGL openssl dbus # for nvidia-powerd ]); ] ); # maybe silly since we've ignored this previously and just unfree.. throwLicense = throw '' Loading Loading @@ -139,35 +146,46 @@ let 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 [ 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 [ 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 [ 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}"; else throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}"; patches = if libsOnly then Loading @@ -186,7 +204,8 @@ let inherit (stdenv.hostPlatform) system; inherit i686bundled; outputs = [ "out" ] outputs = [ "out" ] ++ lib.optional i686bundled "lib32" ++ lib.optional (!libsOnly) "bin" ++ lib.optional (!libsOnly && firmware) "firmware"; Loading @@ -195,14 +214,20 @@ let kernel = if libsOnly then null else kernel.dev; kernelVersion = if libsOnly then null else kernel.modDirVersion; makeFlags = lib.optionals (!libsOnly) (kernel.makeFlags ++ [ makeFlags = lib.optionals (!libsOnly) ( kernel.makeFlags ++ [ "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" ]); ] ); hardeningDisable = [ "pic" "format" ]; hardeningDisable = [ "pic" "format" ]; dontStrip = true; dontPatchELF = true; Loading @@ -210,19 +235,36 @@ let libPath = libPathFor pkgs; libPath32 = lib.optionalString i686bundled (libPathFor pkgsi686Linux); nativeBuildInputs = [ perl nukeReferences which libarchive jq ] ++ lib.optionals (!libsOnly) kernel.moduleBuildDependencies; nativeBuildInputs = [ perl nukeReferences which libarchive jq ] ++ lib.optionals (!libsOnly) kernel.moduleBuildDependencies; disallowedReferences = lib.optionals (!libsOnly) [ kernel.dev ]; passthru = let fetchFromGithubOrNvidia = { owner, repo, rev, ... }@args: fetchFromGithubOrNvidia = { owner, repo, rev, ... }@args: let args' = builtins.removeAttrs args [ "owner" "repo" "rev" ]; args' = builtins.removeAttrs args [ "owner" "repo" "rev" ]; baseUrl = "https://github.com/${owner}/${repo}"; in fetchzip (args' // { fetchzip ( args' // { urls = [ "${baseUrl}/archive/${rev}.tar.gz" "https://download.nvidia.com/XFree86/${repo}/${repo}-${rev}.tar.bz2" Loading @@ -230,11 +272,13 @@ let # 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 { open = lib.mapNullable ( hash: callPackage ./open.nix { inherit hash; nvidia_x11 = self; patches = Loading @@ -244,43 +288,56 @@ let }) patches) ++ patchesOpen; broken = brokenOpen; }) openSha256; } ) openSha256; settings = if useSettings then (if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256) (if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256) { withGtk2 = preferGtk2; withGtk3 = !preferGtk2; fetchFromGitHub = fetchFromGithubOrNvidia; } else { }; } else { }; persistenced = if usePersistenced then lib.mapNullable (hash: callPackage (import ./persistenced.nix self hash) { lib.mapNullable ( hash: callPackage (import ./persistenced.nix self hash) { fetchFromGitHub = fetchFromGithubOrNvidia; }) persistencedSha256 else { }; } ) persistencedSha256 else { }; fabricmanager = if useFabricmanager then lib.mapNullable (hash: callPackage (import ./fabricmanager.nix self hash) { }) fabricmanagerSha256 else { }; else { }; inherit persistencedVersion settingsVersion; compressFirmware = false; ibtSupport = ibtSupport || (lib.versionAtLeast version "530"); } // lib.optionalAttrs (!i686bundled) { } // 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"; description = "${ if useFabricmanager then "Data Center" else "X.org" } driver and kernel module for NVIDIA cards"; license = licenses.unfreeRedistributable; platforms = [ "x86_64-linux" ] platforms = [ "x86_64-linux" ] ++ lib.optionals (sha256_32bit != null) [ "i686-linux" ] ++ lib.optionals (sha256_aarch64 != null) [ "aarch64-linux" ]; maintainers = with maintainers; [ kiskae edwtjo ]; maintainers = with maintainers; [ kiskae edwtjo ]; priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so" inherit broken; }; Loading pkgs/os-specific/linux/nvidia-x11/open.nix +52 −41 Original line number Diff line number Diff line { stdenv , lib , fetchFromGitHub , kernel , nvidia_x11 , hash , patches ? [ ] , broken ? false { stdenv, lib, fetchFromGitHub, kernel, nvidia_x11, hash, patches ? [ ], broken ? false, }: stdenv.mkDerivation ({ stdenv.mkDerivation ( { pname = "nvidia-open"; version = "${kernel.version}-${nvidia_x11.version}"; Loading @@ -30,7 +32,8 @@ stdenv.mkDerivation ({ { aarch64-linux = "TARGET_ARCH=aarch64"; x86_64-linux = "TARGET_ARCH=x86_64"; }.${stdenv.hostPlatform.system} } .${stdenv.hostPlatform.system} ]; installTargets = [ "modules_install" ]; Loading @@ -39,11 +42,19 @@ stdenv.mkDerivation ({ 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" ]; license = with licenses; [ gpl2Plus mit ]; platforms = [ "x86_64-linux" "aarch64-linux" ]; maintainers = with maintainers; [ nickcao ]; inherit broken; }; } // lib.optionalAttrs stdenv.hostPlatform.isAarch64 { } // lib.optionalAttrs stdenv.hostPlatform.isAarch64 { env.NIX_CFLAGS_COMPILE = "-fno-stack-protector"; }) } ) pkgs/os-specific/linux/nvidia-x11/settings.nix +93 −58 Original line number Diff line number Diff line 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 { 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 Loading @@ -35,7 +36,10 @@ let meta = with lib; { homepage = "https://www.nvidia.com/object/unix.html"; platforms = nvidia_x11.meta.platforms; maintainers = with maintainers; [ abbradar aidalgol ]; maintainers = with maintainers; [ abbradar aidalgol ]; }; libXNVCtrl = stdenv.mkDerivation { Loading @@ -43,7 +47,10 @@ let version = nvidia_x11.settingsVersion; inherit src; buildInputs = [ libXrandr libXext ]; buildInputs = [ libXrandr libXext ]; preBuild = '' cd src/libXNVCtrl Loading @@ -57,8 +64,12 @@ let 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) ( if lib.versionOlder nvidia_x11.settingsVersion "400" then ./libxnvctrl-build-shared-3xx.patch else ./libxnvctrl-build-shared.patch ) ]; installPhase = '' Loading @@ -79,7 +90,9 @@ let }; runtimeDependencies = [ libglvnd libXrandr libXv libglvnd libXrandr libXv ]; runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies; Loading @@ -92,15 +105,17 @@ stdenv.mkDerivation { inherit src; patches = lib.optional (lib.versionOlder nvidia_x11.settingsVersion "440") (fetchpatch { 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")) ( (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"; Loading @@ -122,20 +137,40 @@ stdenv.mkDerivation { fi ''; nativeBuildInputs = [ pkg-config m4 addDriverRunpath ] ++ lib.optionals withGtk3 [ wrapGAppsHook3 ]; buildInputs = [ jansson libXv libXrandr libXext libXxf86vm libvdpau nvidia_x11 dbus vulkan-headers ] 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 ]; ++ lib.optionals withGtk3 [ gtk3 librsvg ]; installFlags = [ "PREFIX=$(out)" ]; postInstall = lib.optionalString (!withGtk2) '' postInstall = lib.optionalString (!withGtk2) '' rm -f $out/lib/libnvidia-gtk2.so.* '' + lib.optionalString (!withGtk3) '' '' + 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 Loading Loading
nixos/modules/hardware/video/nvidia.nix +36 −26 Original line number Diff line number Diff line Loading @@ -92,7 +92,8 @@ in information, see the NVIDIA docs, on Chapter 23. Dynamic Boost on Linux ''; modesetting.enable = lib.mkEnableOption '' modesetting.enable = lib.mkEnableOption '' kernel modesetting when using the NVIDIA proprietary driver. Enabling this fixes screen tearing when using Optimus via PRIME (see Loading @@ -103,7 +104,8 @@ in Enabling this and using version 545 or newer of the proprietary NVIDIA driver causes it to provide its own framebuffer device, which can cause Wayland compositors to work when they otherwise wouldn't. '' // { '' // { default = lib.versionAtLeast cfg.package.version "535"; defaultText = lib.literalExpression "lib.versionAtLeast cfg.package.version \"535\""; }; Loading Loading @@ -266,9 +268,11 @@ in ''; }; gsp.enable = lib.mkEnableOption '' gsp.enable = lib.mkEnableOption '' the GPU System Processor (GSP) on the video card '' // { '' // { default = useOpenModules || lib.versionAtLeast nvidia_x11.version "555"; defaultText = lib.literalExpression '' config.hardware.nvidia.open == true || lib.versionAtLeast config.hardware.nvidia.package.version "555" Loading Loading @@ -323,7 +327,9 @@ in softdep nvidia post: nvidia-uvm ''; }; systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [ "L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin" ]; systemd.tmpfiles.rules = lib.mkIf config.virtualisation.docker.enableNvidia [ "L+ /run/nvidia-docker/bin - - - - ${nvidia_x11.bin}/origBin" ]; services.udev.extraRules = '' # Create /dev/nvidia-uvm when the nvidia-uvm module is loaded. KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c 195 255'" Loading Loading @@ -622,7 +628,9 @@ in # If requested enable modesetting via kernel parameters. kernelParams = lib.optional (offloadCfg.enable || cfg.modesetting.enable) "nvidia-drm.modeset=1" ++ lib.optional ((offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545") "nvidia-drm.fbdev=1" ++ lib.optional ( (offloadCfg.enable || cfg.modesetting.enable) && lib.versionAtLeast nvidia_x11.version "545" ) "nvidia-drm.fbdev=1" ++ lib.optional cfg.powerManagement.enable "nvidia.NVreg_PreserveVideoMemoryAllocations=1" ++ lib.optional useOpenModules "nvidia.NVreg_OpenRmEnableUnsupportedGpus=1" ++ lib.optional (config.boot.kernelPackages.kernel.kernelAtLeast "6.2" && !ibtSupport) "ibt=off"; Loading Loading @@ -683,7 +691,9 @@ in TOPOLOGY_FILE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch"; DATABASE_PATH = "${nvidia_x11.fabricmanager}/share/nvidia-fabricmanager/nvidia/nvswitch"; }; nv-fab-conf = settingsFormat.generate "fabricmanager.conf" (fabricManagerConfDefaults // cfg.datacenter.settings); nv-fab-conf = settingsFormat.generate "fabricmanager.conf" ( fabricManagerConfDefaults // cfg.datacenter.settings ); in "${lib.getExe nvidia_x11.fabricmanager} -c ${nv-fab-conf}"; LimitCORE = "infinity"; Loading
pkgs/os-specific/linux/nvidia-x11/default.nix +114 −93 Original line number Diff line number Diff line { lib, callPackage, fetchFromGitHub, fetchgit, fetchpatch, stdenv, pkgsi686Linux }: { lib, callPackage, fetchFromGitHub, fetchgit, fetchpatch, stdenv, pkgsi686Linux, }: let generic = args: let generic = args: let imported = import ./generic.nix args; in callPackage imported { lib32 = (pkgsi686Linux.callPackage imported { in callPackage imported { lib32 = (pkgsi686Linux.callPackage imported { libsOnly = true; kernel = null; }).out; }; kernel = callPackage # a hacky way of extracting parameters from callPackage ({ kernel, libsOnly ? false }: if libsOnly then { } else kernel) { }; 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; 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 { Loading Loading @@ -136,7 +153,8 @@ rec { }; # Last one supporting x86 legacy_390 = let legacy_390 = let # Source corresponding to https://aur.archlinux.org/packages/nvidia-390xx-dkms aurPatches = fetchgit { url = "https://aur.archlinux.org/nvidia-390xx-utils.git"; Loading @@ -154,7 +172,8 @@ rec { "gcc-14.patch" "kernel-6.10.patch" ]; in generic { in generic { version = "390.157"; sha256_32bit = "sha256-VdZeCkU5qct5YgDF8Qgv4mP7CVHeqvlqnP/rioD3B5k="; sha256_64bit = "sha256-W+u8puj+1da52BBw+541HxjtxTSVJVPL3HHo/QubMoo="; Loading @@ -173,7 +192,8 @@ rec { ''; }; legacy_340 = let legacy_340 = let # Source corresponding to https://aur.archlinux.org/packages/nvidia-340xx-dkms aurPatches = fetchFromGitHub { owner = "archlinux-jerry"; Loading @@ -198,7 +218,8 @@ rec { "0014-kernel-6.5.patch" "0015-kernel-6.6.patch" ]; in generic { in generic { version = "340.108"; sha256_32bit = "1jkwa1phf0x4sgw8pvr9d6krmmr3wkgwyygrxhdazwyr2bbalci0"; sha256_64bit = "06xp6c0sa7v1b82gf0pq0i5p0vdhmm3v964v0ypw36y0nzqx8wf6"; Loading
pkgs/os-specific/linux/nvidia-x11/generic.nix +188 −131 Original line number Diff line number Diff line { version , url ? null , sha256_32bit ? null , sha256_64bit , sha256_aarch64 ? null , openSha256 ? null , settingsSha256 ? null , settingsVersion ? version , persistencedSha256 ? null , persistencedVersion ? version , fabricmanagerSha256 ? null , fabricmanagerVersion ? version , useGLVND ? true , useProfiles ? true , preferGtk2 ? false , settings32Bit ? false , useSettings ? true , usePersistenced ? true , useFabricmanager ? false , ibtSupport ? false { version, url ? null, sha256_32bit ? null, sha256_64bit, sha256_aarch64 ? null, openSha256 ? null, settingsSha256 ? null, settingsVersion ? version, persistencedSha256 ? null, persistencedVersion ? version, fabricmanagerSha256 ? null, fabricmanagerVersion ? version, 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 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 , perl , nukeReferences , which , libarchive , jq , # Whether to build the libraries only (i.e. not the kernel module or { lib, stdenv, runCommandLocal, patchutils, callPackage, pkgs, pkgsi686Linux, fetchurl, fetchzip, kernel ? null, 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, libsOnly ? false, # don't include the bundled 32-bit libraries on 64-bit platforms, # even if it’s in downloaded binary disable32Bit ? stdenv.hostPlatform.system == "aarch64-linux" disable32Bit ? stdenv.hostPlatform.system == "aarch64-linux", # 32 bit libs only version of this package , lib32 ? null lib32 ? null, # Whether to extract the GSP firmware, datacenter drivers needs to extract the # firmware , firmware ? openSha256 != null || useFabricmanager firmware ? openSha256 != null || useFabricmanager, # Whether the user accepts the NVIDIA Software License , config , acceptLicense ? config.nvidia.acceptLicense or false config, acceptLicense ? config.nvidia.acceptLicense or false, }: assert !libsOnly -> kernel != null; Loading Loading @@ -97,7 +99,11 @@ let pkgSuffix = lib.optionalString (lib.versionOlder version "304") "-pkg0"; i686bundled = lib.versionAtLeast version "391" && !disable32Bit; libPathFor = pkgs: lib.makeLibraryPath (with pkgs; [ libPathFor = pkgs: lib.makeLibraryPath ( with pkgs; [ libdrm xorg.libXext xorg.libX11 Loading @@ -111,7 +117,8 @@ let libGL openssl dbus # for nvidia-powerd ]); ] ); # maybe silly since we've ignored this previously and just unfree.. throwLicense = throw '' Loading Loading @@ -139,35 +146,46 @@ let 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 [ 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 [ 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 [ 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}"; else throw "nvidia-x11 does not support platform ${stdenv.hostPlatform.system}"; patches = if libsOnly then Loading @@ -186,7 +204,8 @@ let inherit (stdenv.hostPlatform) system; inherit i686bundled; outputs = [ "out" ] outputs = [ "out" ] ++ lib.optional i686bundled "lib32" ++ lib.optional (!libsOnly) "bin" ++ lib.optional (!libsOnly && firmware) "firmware"; Loading @@ -195,14 +214,20 @@ let kernel = if libsOnly then null else kernel.dev; kernelVersion = if libsOnly then null else kernel.modDirVersion; makeFlags = lib.optionals (!libsOnly) (kernel.makeFlags ++ [ makeFlags = lib.optionals (!libsOnly) ( kernel.makeFlags ++ [ "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" ]); ] ); hardeningDisable = [ "pic" "format" ]; hardeningDisable = [ "pic" "format" ]; dontStrip = true; dontPatchELF = true; Loading @@ -210,19 +235,36 @@ let libPath = libPathFor pkgs; libPath32 = lib.optionalString i686bundled (libPathFor pkgsi686Linux); nativeBuildInputs = [ perl nukeReferences which libarchive jq ] ++ lib.optionals (!libsOnly) kernel.moduleBuildDependencies; nativeBuildInputs = [ perl nukeReferences which libarchive jq ] ++ lib.optionals (!libsOnly) kernel.moduleBuildDependencies; disallowedReferences = lib.optionals (!libsOnly) [ kernel.dev ]; passthru = let fetchFromGithubOrNvidia = { owner, repo, rev, ... }@args: fetchFromGithubOrNvidia = { owner, repo, rev, ... }@args: let args' = builtins.removeAttrs args [ "owner" "repo" "rev" ]; args' = builtins.removeAttrs args [ "owner" "repo" "rev" ]; baseUrl = "https://github.com/${owner}/${repo}"; in fetchzip (args' // { fetchzip ( args' // { urls = [ "${baseUrl}/archive/${rev}.tar.gz" "https://download.nvidia.com/XFree86/${repo}/${repo}-${rev}.tar.bz2" Loading @@ -230,11 +272,13 @@ let # 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 { open = lib.mapNullable ( hash: callPackage ./open.nix { inherit hash; nvidia_x11 = self; patches = Loading @@ -244,43 +288,56 @@ let }) patches) ++ patchesOpen; broken = brokenOpen; }) openSha256; } ) openSha256; settings = if useSettings then (if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256) (if settings32Bit then pkgsi686Linux.callPackage else callPackage) (import ./settings.nix self settingsSha256) { withGtk2 = preferGtk2; withGtk3 = !preferGtk2; fetchFromGitHub = fetchFromGithubOrNvidia; } else { }; } else { }; persistenced = if usePersistenced then lib.mapNullable (hash: callPackage (import ./persistenced.nix self hash) { lib.mapNullable ( hash: callPackage (import ./persistenced.nix self hash) { fetchFromGitHub = fetchFromGithubOrNvidia; }) persistencedSha256 else { }; } ) persistencedSha256 else { }; fabricmanager = if useFabricmanager then lib.mapNullable (hash: callPackage (import ./fabricmanager.nix self hash) { }) fabricmanagerSha256 else { }; else { }; inherit persistencedVersion settingsVersion; compressFirmware = false; ibtSupport = ibtSupport || (lib.versionAtLeast version "530"); } // lib.optionalAttrs (!i686bundled) { } // 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"; description = "${ if useFabricmanager then "Data Center" else "X.org" } driver and kernel module for NVIDIA cards"; license = licenses.unfreeRedistributable; platforms = [ "x86_64-linux" ] platforms = [ "x86_64-linux" ] ++ lib.optionals (sha256_32bit != null) [ "i686-linux" ] ++ lib.optionals (sha256_aarch64 != null) [ "aarch64-linux" ]; maintainers = with maintainers; [ kiskae edwtjo ]; maintainers = with maintainers; [ kiskae edwtjo ]; priority = 4; # resolves collision with xorg-server's "lib/xorg/modules/extensions/libglx.so" inherit broken; }; Loading
pkgs/os-specific/linux/nvidia-x11/open.nix +52 −41 Original line number Diff line number Diff line { stdenv , lib , fetchFromGitHub , kernel , nvidia_x11 , hash , patches ? [ ] , broken ? false { stdenv, lib, fetchFromGitHub, kernel, nvidia_x11, hash, patches ? [ ], broken ? false, }: stdenv.mkDerivation ({ stdenv.mkDerivation ( { pname = "nvidia-open"; version = "${kernel.version}-${nvidia_x11.version}"; Loading @@ -30,7 +32,8 @@ stdenv.mkDerivation ({ { aarch64-linux = "TARGET_ARCH=aarch64"; x86_64-linux = "TARGET_ARCH=x86_64"; }.${stdenv.hostPlatform.system} } .${stdenv.hostPlatform.system} ]; installTargets = [ "modules_install" ]; Loading @@ -39,11 +42,19 @@ stdenv.mkDerivation ({ 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" ]; license = with licenses; [ gpl2Plus mit ]; platforms = [ "x86_64-linux" "aarch64-linux" ]; maintainers = with maintainers; [ nickcao ]; inherit broken; }; } // lib.optionalAttrs stdenv.hostPlatform.isAarch64 { } // lib.optionalAttrs stdenv.hostPlatform.isAarch64 { env.NIX_CFLAGS_COMPILE = "-fno-stack-protector"; }) } )
pkgs/os-specific/linux/nvidia-x11/settings.nix +93 −58 Original line number Diff line number Diff line 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 { 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 Loading @@ -35,7 +36,10 @@ let meta = with lib; { homepage = "https://www.nvidia.com/object/unix.html"; platforms = nvidia_x11.meta.platforms; maintainers = with maintainers; [ abbradar aidalgol ]; maintainers = with maintainers; [ abbradar aidalgol ]; }; libXNVCtrl = stdenv.mkDerivation { Loading @@ -43,7 +47,10 @@ let version = nvidia_x11.settingsVersion; inherit src; buildInputs = [ libXrandr libXext ]; buildInputs = [ libXrandr libXext ]; preBuild = '' cd src/libXNVCtrl Loading @@ -57,8 +64,12 @@ let 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) ( if lib.versionOlder nvidia_x11.settingsVersion "400" then ./libxnvctrl-build-shared-3xx.patch else ./libxnvctrl-build-shared.patch ) ]; installPhase = '' Loading @@ -79,7 +90,9 @@ let }; runtimeDependencies = [ libglvnd libXrandr libXv libglvnd libXrandr libXv ]; runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies; Loading @@ -92,15 +105,17 @@ stdenv.mkDerivation { inherit src; patches = lib.optional (lib.versionOlder nvidia_x11.settingsVersion "440") (fetchpatch { 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")) ( (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"; Loading @@ -122,20 +137,40 @@ stdenv.mkDerivation { fi ''; nativeBuildInputs = [ pkg-config m4 addDriverRunpath ] ++ lib.optionals withGtk3 [ wrapGAppsHook3 ]; buildInputs = [ jansson libXv libXrandr libXext libXxf86vm libvdpau nvidia_x11 dbus vulkan-headers ] 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 ]; ++ lib.optionals withGtk3 [ gtk3 librsvg ]; installFlags = [ "PREFIX=$(out)" ]; postInstall = lib.optionalString (!withGtk2) '' postInstall = lib.optionalString (!withGtk2) '' rm -f $out/lib/libnvidia-gtk2.so.* '' + lib.optionalString (!withGtk3) '' '' + 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 Loading