Nvidia: Difference between revisions

m Fix broken link
m Correct broken bullet points
 
(8 intermediate revisions by 6 users not shown)
Line 21: Line 21:
== Enable unfree software repositories ==  
== Enable unfree software repositories ==  


Make sure to allow [[Unfree Software|unfree software]]. The unfree NVIDIA packages include <code>nvidia-x11</code>, <code>nvidia-settings</code>, and <code>nvidia-persistenced</code>.
Make sure to allow [[Unfree software|unfree software]]. The unfree NVIDIA packages include <code>nvidia-x11</code>, <code>nvidia-settings</code>, and <code>nvidia-persistenced</code>.
 


== Modifying NixOS configuration ==
== Modifying NixOS configuration ==
Line 34: Line 33:
{
{


   # Enable OpenGL
   # Enable graphics driver in NixOS unstable/NixOS 24.11
   hardware.opengl = {
   hardware.graphics.enable = true;
    enable = true;
  # The same as above but for NixOS 23.11
    driSupport = true;
  #hardware.opengl = {
    driSupport32Bit = true;
  #  enable = true;
   };
  #  driSupport = true;
   #};


   # Load "nvidia" driver for Xorg and Wayland
   # Load "nvidia" driver for Xorg and Wayland
Line 69: Line 69:


     # Enable the Nvidia settings menu,
     # Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
    # accessible via `nvidia-settings`.
     nvidiaSettings = true;
     nvidiaSettings = true;


Line 142: Line 142:
</syntaxhighlight>
</syntaxhighlight>


Note the two values under "bus info" above, which may differ from laptop to laptop. Our Nvidia Bus ID is <code>0e:00.0</code> and our Intel Bus ID is <code>00:02.0</code>. Watch out for the formatting; convert them from hexadecimal to decimal, remove the padding (leading zeroes), replace the dot with a colon, then add them like this:
Note the two values under "bus info" above, which may differ from laptop to laptop. Our Nvidia Bus ID is <code>0e:00.0</code> and our Intel Bus ID is <code>00:02.0</code>.
 
{{Warning|Watch out for the formatting; convert the values from hexadecimal to decimal, remove the padding (leading zeroes), replace the dot with a colon.}}{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
{
hardware.nvidia.prime = {
hardware.nvidia.prime = {
Line 290: Line 289:


Then restart your graphical environment session (or simply reboot).
Then restart your graphical environment session (or simply reboot).
=== Running Specific NVIDIA Driver Versions ===
To run a specific version of the NVIDIA driver in NixOS, you can customize your configuration by specifying the desired version along with the corresponding SHA256 hashes. Below is an example configuration for using NVIDIA driver version `555.58.02`:
{{file|/etc/nixos/nvidia.nix|nix|<nowiki>
  package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
    version = "555.58.02";
    sha256_64bit = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM=";
    sha256_aarch64 = "sha256-xctt4TPRlOJ6r5S54h5W6PT6/3Zy2R4ASNFPu8TSHKM=";
    openSha256 = "sha256-ZpuVZybW6CFN/gz9rx+UJvQ715FZnAOYfHn5jt5Z2C8=";
    settingsSha256 = "sha256-ZpuVZybW6CFN/gz9rx+UJvQ715FZnAOYfHn5jt5Z2C8=";
    persistencedSha256 = lib.fakeSha256;
  };
</nowiki>}}
In this configuration:
* Replace `version` with the desired driver version.
* Update the SHA256 hashes to match the new version you want to use.
* After updating the configuration, run <code>sudo nixos-rebuild switch</code> to apply the changes and load the specified NVIDIA driver version.
This allows you to pin the specific driver version being used in your NixOS installation.


=== Running the new RTX SUPER on NixOS stable ===
=== Running the new RTX SUPER on NixOS stable ===
Line 299: Line 321:


{{file|/etc/nixos/nvidia.nix|nix|<nowiki>
{{file|/etc/nixos/nvidia.nix|nix|<nowiki>
{ pkgs, config, libs, ... }:
{
  pkgs,
  config,
  ...
}:


{
{
  # Enable graphics driver in NixOS unstable/NixOS 24.11
  hardware.graphics.enable = true;
  # The same as above but for NixOS 23.11
  #hardware.opengl = {
  #  enable = true;
  #  driSupport = true;
  #};


# Enable OpenGL
  # Load nvidia driver for Xorg and Wayland
   hardware.opengl = {
   services.xserver.videoDrivers = [ "nvidia" ];
    enable = true;
    driSupport = true;
    driSupport32Bit = true;
  };


# Load nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = ["nvidia"];
 
   hardware.nvidia.modesetting.enable = true;
   hardware.nvidia.modesetting.enable = true;
   hardware.nvidia.powerManagement.enable = false;
   hardware.nvidia.powerManagement.enable = false;
Line 318: Line 344:
   hardware.nvidia.open = false;
   hardware.nvidia.open = false;
   hardware.nvidia.nvidiaSettings = true;
   hardware.nvidia.nvidiaSettings = true;
# Special config to load the latest (535 or 550) driver for the support of the 4070 SUPER
  # Special config to load the latest (535 or 550) driver for the support of the 4070 SUPER
   hardware.nvidia.package = let  
   hardware.nvidia.package =
  rcu_patch = pkgs.fetchpatch {
    let
    url = "https://github.com/gentoo/gentoo/raw/c64caf53/x11-drivers/nvidia-drivers/files/nvidia-drivers-470.223.02-gpl-pfn_valid.patch";
      rcu_patch = pkgs.fetchpatch {
    hash = "sha256-eZiQQp2S/asE7MfGvfe6dA/kdCvek9SYa/FFGp24dVg=";
        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=";
in config.boot.kernelPackages.nvidiaPackages.mkDriver {
      };
    version = "535.154.05";
    in
    sha256_64bit = "sha256-fpUGXKprgt6SYRDxSCemGXLrEsIA6GOinp+0eGbqqJg=";
    config.boot.kernelPackages.nvidiaPackages.mkDriver {
    sha256_aarch64 = "sha256-G0/GiObf/BZMkzzET8HQjdIcvCSqB1uhsinro2HLK9k=";
      version = "535.154.05";
    openSha256 = "sha256-wvRdHguGLxS0mR06P5Qi++pDJBCF8pJ8hr4T8O6TJIo=";
      sha256_64bit = "sha256-fpUGXKprgt6SYRDxSCemGXLrEsIA6GOinp+0eGbqqJg=";
    settingsSha256 = "sha256-9wqoDEWY4I7weWW05F4igj1Gj9wjHsREFMztfEmqm10=";
      sha256_aarch64 = "sha256-G0/GiObf/BZMkzzET8HQjdIcvCSqB1uhsinro2HLK9k=";
    persistencedSha256 = "sha256-d0Q3Lk80JqkS1B54Mahu2yY/WocOqFFbZVBh+ToGhaE=";
      openSha256 = "sha256-wvRdHguGLxS0mR06P5Qi++pDJBCF8pJ8hr4T8O6TJIo=";
      settingsSha256 = "sha256-9wqoDEWY4I7weWW05F4igj1Gj9wjHsREFMztfEmqm10=";
      persistencedSha256 = "sha256-d0Q3Lk80JqkS1B54Mahu2yY/WocOqFFbZVBh+ToGhaE=";


    #version = "550.40.07";
      #version = "550.40.07";
    #sha256_64bit = "sha256-KYk2xye37v7ZW7h+uNJM/u8fNf7KyGTZjiaU03dJpK0=";
      #sha256_64bit = "sha256-KYk2xye37v7ZW7h+uNJM/u8fNf7KyGTZjiaU03dJpK0=";
    #sha256_aarch64 = "sha256-AV7KgRXYaQGBFl7zuRcfnTGr8rS5n13nGUIe3mJTXb4=";
      #sha256_aarch64 = "sha256-AV7KgRXYaQGBFl7zuRcfnTGr8rS5n13nGUIe3mJTXb4=";
    #openSha256 = "sha256-mRUTEWVsbjq+psVe+kAT6MjyZuLkG2yRDxCMvDJRL1I=";
      #openSha256 = "sha256-mRUTEWVsbjq+psVe+kAT6MjyZuLkG2yRDxCMvDJRL1I=";
    #settingsSha256 = "sha256-c30AQa4g4a1EHmaEu1yc05oqY01y+IusbBuq+P6rMCs=";
      #settingsSha256 = "sha256-c30AQa4g4a1EHmaEu1yc05oqY01y+IusbBuq+P6rMCs=";
    #persistencedSha256 = "sha256-11tLSY8uUIl4X/roNnxf5yS2PQvHvoNjnd2CB67e870=";
      #persistencedSha256 = "sha256-11tLSY8uUIl4X/roNnxf5yS2PQvHvoNjnd2CB67e870=";


    patches = [ rcu_patch ];
      patches = [ rcu_patch ];
};
    };
}
}
</nowiki>}}
</nowiki>}}
Line 398: Line 426:


Be warned that the Nvidia open driver is considered "beta quality". Performance may be very slightly lower.
Be warned that the Nvidia open driver is considered "beta quality". Performance may be very slightly lower.
(Update to be incorporated: Nvidia has [https://developer.nvidia.com/blog/nvidia-transitions-fully-towards-open-source-gpu-kernel-modules/ announced in July 2024] that the upcoming version R560 will "fully transisition" towards the open-source kernel module. This means that the default kernel module installed by Nvidia scripts will be the open-source one. This is justified as the open-source driver is now as stable and performant as (if not more than) the closed-sourced driver. The new driver only applies to Turing and later GPUs; older hardware with Maxwell, Pascal, or Volta will still require the proprietary version.)


= Disable Nvidia dGPU completely =
= Disable Nvidia dGPU completely =