Nvidia: Difference between revisions

From NixOS Wiki
imported>Vodkabot
No edit summary
imported>Vodkabot
No edit summary
Line 1: Line 1:
For Optimus hybrid graphics there are currently two solutions available under NixOS:
For Optimus hybrid graphics there are currently two solutions available under NixOS:


1. '''Bumblebee'''
== Bumblebee ==


Use <syntaxHighlight lang="nix">hardware.bumblebee.enable = true;</syntaxHighlight> option.
Use <syntaxHighlight lang="nix">hardware.bumblebee.enable = true;</syntaxHighlight> option.
Line 10: Line 10:
Cons: some performance penalty, no Vulkan support, things like CUDA and OpenCL are problematic to configure
Cons: some performance penalty, no Vulkan support, things like CUDA and OpenCL are problematic to configure


2. '''Nvidia PRIME'''
== Nvidia PRIME ==


Use the [https://github.com/dukzcry/crap/tree/master/primerun special script] for out of box experience.
Use the [https://github.com/dukzcry/crap/tree/master/primerun special script] for out of box experience.

Revision as of 14:14, 26 April 2018

For Optimus hybrid graphics there are currently two solutions available under NixOS:

Bumblebee

Use

hardware.bumblebee.enable = true;

option.


Pros: out of box experience, just start the game via primusrun or optirun wrapper

Cons: some performance penalty, no Vulkan support, things like CUDA and OpenCL are problematic to configure

Nvidia PRIME

Use the special script for out of box experience.

Configure NixOS to allow Intel and Nvidia X.Org drivers coexist together, and also to disable nvidia card by default. Requires NixOS version with https://github.com/NixOS/nixpkgs/pull/37369 merged

/etc/nixos/configuration.nix
let
  # nvidia packages to use
  nvidia = pkgs.linuxPackages.nvidia_x11;
  nvidia32 = pkgs_i686.linuxPackages.nvidia_x11;
in
{
  # disable card with bbswitch by default
  hardware.nvidiaOptimus.disable = true;
  # load kernel modules
  boot.extraModulePackages = [ nvidia.bin ];
  # install nvidia drivers in addition to intel one
  hardware.opengl.extraPackages = [ nvidia.out ];
  hardware.opengl.extraPackages32 = [ nvidia32.out ];
}

Similar to Bumblebee, start the game via primerun.sh.

Pros: better performance, Vulkan is supported. CUDA and OpenCL should work, though CUDA needs an additional device creation rule https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/hardware/video/nvidia.nix#L66

Cons: there are still some rough edges noted on the top of script, but otherwise it works fine for me.