Can't use Nvidia offload mode

Sorry, yet another offload mode post… I didn’t find the solution in others posts :frowning:

Here the output of Lutris in Offload mode:

[eyome@nixos:~]$ nvidia-offload lutris
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  150 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  50
  Current serial number in output stream:  51
2023-05-01 20:59:14,081: ['glxinfo', '-B'] command failed: Command '['glxinfo', '-B']' returned non-zero exit status 1.
2023-05-01 20:59:14,081: No available glxinfo output
2023-05-01 20:59:14,082: Invalid glxinfo received
2023-05-01 20:59:14,967: Starting Lutris 0.5.12
2023-05-01 20:59:15,084: glxinfo is not available on your system, unable to detect driver version
2023-05-01 20:59:15,084: GPU: 8086:0166 17AA:21F5 (i915 drivers)
MESA-INTEL: warning: Ivy Bridge Vulkan support is incomplete

(lutris:2675): Gtk-CRITICAL **: 20:59:15.299: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
2023-05-01 20:59:15,560: Startup complete
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  150 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  50
  Current serial number in output stream:  51
2023-05-01 20:59:44,722: ['glxinfo', '-B'] command failed: Command '['glxinfo', '-B']' returned non-zero exit status 1.
2023-05-01 20:59:44,722: No available glxinfo output
MESA-INTEL: warning: Ivy Bridge Vulkan support is incomplete

It seems my Nvidia card is not recognize.

Here my configuration.nix:

## Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

#let
#  nix-software-center = (import (pkgs.fetchFromGitHub {
#    owner = "vlinkz";
#    repo = "nix-software-center";
#    rev = "0.1.2";
#    sha256 = "xiqF1mP8wFubdsAQ1BmfjzCgOD3YZf7EGWl9i69FTls=";
#  })) {};
#in


{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ./nvidia.nix
    ];

  # Bootloader.
  boot.loader.grub.enable = true;
  boot.loader.grub.device = "/dev/sda";
#  boot.loader.grub.useOSProber = true;
 
  # Enable ntfs partition
  boot.supportedFilesystems = [ "ntfs" ];

  system.fsPackages = [ pkgs.ntfs3g ];
  fileSystems."/mnt/Commune" =
    { device = "/dev/disk/by-uuid/688BFB195753AE87";
      fsType = "ntfs3";
      options = ["force" "rw" "uid=1000" "nofail"];
    };

  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Europe/Paris";

  # Select internationalisation properties.
  i18n.defaultLocale = "fr_FR.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "fr_FR.UTF-8";
    LC_IDENTIFICATION = "fr_FR.UTF-8";
    LC_MEASUREMENT = "fr_FR.UTF-8";
    LC_MONETARY = "fr_FR.UTF-8";
    LC_NAME = "fr_FR.UTF-8";
    LC_NUMERIC = "fr_FR.UTF-8";
    LC_PAPER = "fr_FR.UTF-8";
    LC_TELEPHONE = "fr_FR.UTF-8";
    LC_TIME = "fr_FR.UTF-8";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;

  # Configure keymap in X11
  services.xserver = {
    layout = "fr";
    xkbVariant = "";
  };

  # Configure console keymap
  console.keyMap = "fr";

  # Enable CUPS to print documents.
  services.printing.enable = true;
  services.avahi.enable = true;
  services.avahi.nssmdns = true;
  # for a WiFi printer
  services.avahi.openFirewall = true;

  # Enable scanner
  services.saned.enable = true;
  hardware.sane.enable = true;
  hardware.sane.openFirewall = true;
  services.ipp-usb.enable = true;
  hardware.sane.extraBackends = [ pkgs.sane-airscan ];

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.eyome = {
    isNormalUser = true;
    description = "eyome";
    extraGroups = [ "networkmanager" "wheel" "scanners" "lp" ];
    packages = with pkgs; [
      amberol
      bottles
      curtail
      dino
      drawing
      firefox
      fragments
      fuse
      gnomeExtensions.gsconnect
      gnome.gnome-boxes
      gnome-firmware
      gnome-frog
      gnome.gnome-software
      gnome.gnome-tweaks
      kodi
      libreoffice-fresh
      lutris
      material-design-icons
      mesa
      mousai
      neofetch
      nix-diff
      nixos-option
#      nix-software-center
      noto-fonts-emoji
      ntfs3g
#      rustdesk
      sane-airscan
      shortwave
      ungoogled-chromium
    ];
  };

  # Enabled Gsconnect
  programs.kdeconnect = {
      enable = true;
      package = pkgs.gnomeExtensions.gsconnect;
  };

  # Enabled Flatpak
  services.flatpak.enable = true;

  # Enabled Fwupd
  services.fwupd.enable = true;

  # Gnome paquets exlusion
  environment.gnome.excludePackages = [ pkgs.gnome-tour pkgs.gnome.geary ];
  environment.systemPackages = [
  ];

  # Others paquets exlusion 
  services.xserver.excludePackages = [ pkgs.xterm ];

  # Enable virtualisation
  virtualisation.libvirtd.enable = true;

  # Experimental paquet inclusion
  nix.extraOptions = ''experimental-features = nix-command flakes'';

  # Enable automatic login for the user.
  services.xserver.displayManager.autoLogin.enable = true;
  services.xserver.displayManager.autoLogin.user = "eyome";

  # Workaround for GNOME autologin
  systemd.services."getty@tty1".enable = false;
  systemd.services."autovt@tty1".enable = false;

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # Enable OpenGL for 32-bit programs such as in Wine
  hardware.opengl.driSupport32Bit = true;

  # NVIDIA drivers
  hardware.nvidia.modesetting.enable = true;
  hardware.opengl.enable = true;

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "22.11"; # Did you read the comment?

}

Here my Nvidia.nix:

{ pkgs, ... }:

let
  nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
    export __NV_PRIME_RENDER_OFFLOAD=1
    export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
    export __GLX_VENDOR_LIBRARY_NAME=nvidia
    export __VK_LAYER_NV_optimus=NVIDIA_only
    exec "$@"
  '';
in {
  environment.systemPackages = [ nvidia-offload ];

  services.xserver.videoDrivers = [ "nvidia" ];
  hardware.nvidia.prime = {
    offload.enable = true;

    # Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA
    intelBusId = "PCI:0:2:0";

    # Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA
    nvidiaBusId = "PCI:1:0:0";
  };
}

And here my lspci:

[nix-shell:~]$ lspci
00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)
00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)
00:16.0 Communication controller: Intel Corporation 7 Series/C216 Chipset Family MEI Controller #1 (rev 04)
00:16.3 Serial controller: Intel Corporation 7 Series/C210 Series Chipset Family KT Controller (rev 04)
00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (Lewisville) (rev 04)
00:1a.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 7 Series/C216 Chipset Family PCI Express Root Port 1 (rev c4)
00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4)
00:1c.2 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3 (rev c4)
00:1d.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation QM77 Express Chipset LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation 7 Series/C216 Chipset Family SMBus Controller (rev 04)
01:00.0 VGA compatible controller: NVIDIA Corporation GK107GLM [Quadro K1000M] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GK107 HDMI Audio Controller (rev a1)
02:00.0 System peripheral: Ricoh Co Ltd MMC/SD Host Controller (rev 08)
02:00.3 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 PCIe IEEE 1394 Controller (rev 04)
03:00.0 Network controller: Intel Corporation Centrino Advanced-N 6205 [Taylor Peak] (rev 34)

Could someone help me?..

Have you tried adding glxinfo to your packages? The error is saying that it can’t find glxinfo, which it apparently needs to figure out what driver version you’re running.

To check if your nvidia-offload script works at all, I’d recommend trying the glxgears demo from mesa-demos instead of something as convoluted as lutris.

I don’t have much experience with lutris, but given it’s a wrapper around wine, it probably messes with environment variables. There’s a chance it removes the variables set by your nvidia-offload script? There may be a setting in Lutris to toggle offload mode, I know bottles has one.

Hi TLATER, thank you foryour help!

Here the output of Lutris and trying to launch Epic Store after installing glxinfo:

nvidia-offload lutris
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  150 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  50
  Current serial number in output stream:  51
2023-05-02 22:30:47,897: ['glxinfo', '-B'] command failed: Command '['glxinfo', '-B']' returned non-zero exit status 1.
2023-05-02 22:30:47,898: No available glxinfo output
2023-05-02 22:30:47,898: Invalid glxinfo received
2023-05-02 22:30:49,002: Starting Lutris 0.5.12
2023-05-02 22:30:49,150: glxinfo is not available on your system, unable to detect driver version
2023-05-02 22:30:49,151: GPU: 8086:0166 17AA:21F5 (i915 drivers)
MESA-INTEL: warning: Ivy Bridge Vulkan support is incomplete

(lutris:2168): Gtk-CRITICAL **: 22:30:49.560: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
2023-05-02 22:30:49,935: Startup complete
2023-05-02 22:36:09,402: Runtime disabled by system configuration
2023-05-02 22:36:09,403: Dialog hide-wine-systemwide-install-warning dismissed by user
2023-05-02 22:36:09,662: Runtime disabled by system configuration
MESA-INTEL: warning: Ivy Bridge Vulkan support is incomplete
2023-05-02 22:36:09,725: Runtime disabled by system configuration
Discord ID: None
2023-05-02 22:36:09,764: Discord RPC Disabled or Discord APP ID Not Present
lutris-wrapper: Epic Games Store
Started initial process 2917 from /home/eyome/.local/share/lutris/runners/wine/lutris-GE-Proton7-43-x86_64/bin/wine /mnt/Commune/Jeux PC/drive_c/Program Files (x86)/Epic Games/Launcher/Portal/Binaries/Win32/EpicGamesLauncher.exe -opengl -SkipBuildPatchPrereq
Start monitoring process.
fsync: up and running.
wine: RLIMIT_NICE is <= 20, unable to use setpriority safely
MESA-INTEL: warning: Ivy Bridge Vulkan support is incomplete
Monitored process exited.
Initial process has exited (return code: 13568)
Exit with return code 13568
2023-05-02 22:36:11,767: Game still running (state: running)
2023-05-02 22:36:11,767: Stopping Epic Games Store (wine)
2023-05-02 22:36:11,767: The game has run for a very short time, did it crash?

It’s like glxinfo is not installed…

Here the output of glxgears:

[eyome@nixos:~]$ glxgears
Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
304 frames in 5.0 seconds = 60.681 FPS
298 frames in 5.0 seconds = 59.429 FPS
298 frames in 5.0 seconds = 59.598 FPS
299 frames in 5.0 seconds = 59.682 FPS
297 frames in 5.0 seconds = 59.324 FPS
^Z
[1]+  Stoppé                 glxgears

And the other with nvidia-offload:

[eyome@nixos:~]$ nvidia-offload glxgears
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  150 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  26
  Current serial number in output stream:  27

I have never used Nvidia card on Linux (and above all offload mode) so I may forget something obvious for Nvidia users…

Hrm, I can also only guess, been using nvidia for a long, time, and have regretted it almost since day one.

So you have two problems - lutris is apparently lacking glxinfo in its path and your nvidia driver isn’t working (as usual, thanks nvidia).


What if you run glxinfo -B without lutris? Apparently the package should be set up with glxinfo already. Did you accidentally install lutris from some third party repository in addition to the one installed with home.packages? What does command -v lutris give you?

Could also you delete ~/.local/share/lutris, just in case there’s some kind of caching (note this will likely clear out all your currently installed prefixes)?

While you’re at it, I am pretty sure I was correct about lutris needing some special handling to manage running from your nvidia GPU. Check out this issue: Lutris doesn't use Nvidia GPU in dual graphics laptop · Issue #209408 · NixOS/nixpkgs · GitHub


Never used prime, but:

That option is documented to prevent screen tearing with prime, however it’s only mentioned with sync mode, and the nixos-hardware module doesn’t set it by default. Perhaps it’s causing issues?

On the other hand, the default.nix does set it, and I’ve never seen anyone else struggle with this.

Edit: Heh, missed the imports = [./.];, and I wrote the file. It’s probably not caused by modesetting.

If removing that doesn’t fix it, it would be nice to see your session logs. You’re on gnome, which is wayland now, but I believe you should still be able to get those logs with journalctl --boot -t xsession. Would be best if you kept it to only the logs after rebooting and running glxgears, there will be a lot to parse.

I’ve been using offload successfully for years now. I have a module where only the first few lines should be all you really need:

finegrained may need to be switched off on older cards, but that’s about it.

1 Like
[eyome@nixos:~]$ glxinfo -B
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Intel (0x8086)
    Device: Mesa Intel(R) HD Graphics 4000 (IVB GT2) (0x166)
    Version: 23.0.3
    Accelerated: yes
    Video memory: 1536MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.2
    Max compat profile version: 4.2
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) HD Graphics 4000 (IVB GT2)
OpenGL core profile version string: 4.2 (Core Profile) Mesa 23.0.3
OpenGL core profile shading language version string: 4.20
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.2 (Compatibility Profile) Mesa 23.0.3
OpenGL shading language version string: 4.20
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 23.0.3
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

I have installed Lutris from Nixos repo, then from Flathub, and Nixos repo again. I had various problems on each sources so I decided to keep and investigate the Nixos repo one (and delete the Flathub one).

[eyome@nixos:~]$ command -v lutris
/etc/profiles/per-user/eyome/bin/lutris

The output fter deleting ~/.local/share/lutris:

[eyome@nixos:~]$ nvidia-offload lutris
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  150 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  50
  Current serial number in output stream:  51
2023-05-02 23:42:55,386: ['glxinfo', '-B'] command failed: Command '['glxinfo', '-B']' returned non-zero exit status 1.
2023-05-02 23:42:55,386: No available glxinfo output
2023-05-02 23:42:55,386: Invalid glxinfo received
2023-05-02 23:42:56,042: Starting Lutris 0.5.12
2023-05-02 23:42:56,159: glxinfo is not available on your system, unable to detect driver version
2023-05-02 23:42:56,160: GPU: 8086:0166 17AA:21F5 (i915 drivers)
MESA-INTEL: warning: Ivy Bridge Vulkan support is incomplete

(lutris:4836): Gtk-CRITICAL **: 23:42:56.233: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
2023-05-02 23:42:56,483: Startup complete

[eyome@nixos:~]$ journalctl --boot -t xsession
-- No entries --

Sorry? I miss something? :sweat_smile:

You seem to already be running the same configuration as @nrdxp as well.

What about nvidia-offload glxinfo -B? I wonder if that simply fails, and that lutris then reports it as not present.

You might need to set logToJournal.

It’s enabled by default, though. I’m guessing it’s not run for wayland sessions, in which case sadly I don’t know how to get your gnome session logs.

Hello there!

@nrdxp, thank you but my config looks the same as mine and it doesn’t work for me :frowning:

[eyome@nixos:~]$ nvidia-offload glxinfo -B
name of display: :0
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  150 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  50
  Current serial number in output stream:  51

Regarding the logs, I have found Gnome-logs, I think it’s enough? I searched “Nvi”:

21:58:21 kernel: nvidia-nvlink: Unregistered Nvlink Core, major device number 238
21:58:21 kernel: NVRM: No NVIDIA GPU found.
21:58:21 kernel: nvidia-nvlink: Nvlink Core is being initialized, major device number 238
21:58:21 kernel: input: HDA NVidia HDMI/DP,pcm=9 as /devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1/input22
21:58:21 kernel: nvidia-nvlink: Unregistered Nvlink Core, major device number 238
21:58:21 kernel: NVRM: No NVIDIA GPU found.
21:58:21 kernel: nvidia-nvlink: Nvlink Core is being initialized, major device number 238
21:58:20 kernel: NVRM: No NVIDIA GPU found.
21:58:20 kernel: nvidia-nvlink: Nvlink Core is being initialized, major device number 242
21:58:20 kernel: NVRM: No NVIDIA GPU found.
21:58:20 kernel: nvidia-nvlink: Nvlink Core is being initialized, major device number 245
21:58:20 kernel: nvidia: module license 'NVIDIA' taints kernel.
21:58:19 kernel:   with environment:
21:58:19 kernel: Kernel command line: BOOT_IMAGE=(hd0,msdos1)/nix/store/n1q4w3mms6xqdcpwb9ahnzsijqr3b6xj-linux-6.1.26/bzImage init=/nix/store/0wy4izhjps5gx94qw732znj6lds813w8-nixos-system-nixos-23.05pre480050.1a411f23ba2/init loglevel=4 nvidia-drm.modeset=1
21:58:19 kernel: Command line: BOOT_IMAGE=(hd0,msdos1)/nix/store/n1q4w3mms6xqdcpwb9ahnzsijqr3b6xj-linux-6.1.26/bzImage init=/nix/store/0wy4izhjps5gx94qw732znj6lds813w8-nixos-system-nixos-23.05pre480050.1a411f23ba2/init loglevel=4 nvidia-drm.modeset=1

Other thing: I check the bios settings and I get:
“Graphics device: Nvidia Optimus
OS detection for Nvidia Optimus: Enabled”
So it seems good for me on that side.

22:03:27 systemd: plymouth-quit.service: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.
21:58:23 (uetoothd): sap-server: Operation not permitted (1)
21:58:21 kernel: Bluetooth: hci0: BCM: 'brcm/BCM-0a5c-21e6.hcd'
21:58:21 kernel: 
21:58:21 systemd-modules: Failed to insert module 'nvidia_modeset': Device or resource busy
21:58:21 kernel: NVRM: The NVIDIA Quadro K1000M GPU installed in this system is
NVRM:  supported through the NVIDIA 470.xx Legacy drivers. Please
NVRM:  visit http://www.nvidia.com/object/unix.html for more
NVRM:  information.  The 530.41.03 NVIDIA driver will ignore
NVRM:  this GPU.  Continuing probe...
21:58:20 kernel: 
21:58:20 kernel: plymouth-quit.service: Service has no ExecStart=, ExecStop=, or SuccessAction=. Refusing.

Oh, I need Legacy drivers, right? How to specify it?

Ahhhhhh, yes, I was wondering if that card was a little old, but 2012 didn’t seem that long ago. Joke’s on me, I’m old…

You need hardware.nvidia.package:

hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
1 Like

My good old W530 :smiley:

ok, we are close, I tried to add this on my nvidia.nix:

{ pkgs, ... }:

let
  nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
    export __NV_PRIME_RENDER_OFFLOAD=1
    export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
    export __GLX_VENDOR_LIBRARY_NAME=nvidia
    export __VK_LAYER_NV_optimus=NVIDIA_only
    exec "$@"
  '';
in {
  environment.systemPackages = [ nvidia-offload ];

  services.xserver.videoDrivers = [ "nvidia" ];
  hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
  hardware.nvidia.prime = {
    offload.enable = true;

    # Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA
    intelBusId = "PCI:0:2:0";

    # Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA
    nvidiaBusId = "PCI:1:0:0";
  };
}

But I get this error:

[eyome@nixos:~]$ sudo nixos-rebuild switch
error: undefined variable 'config'

       at /etc/nixos/nvidia.nix:15:29:

           14|   services.xserver.videoDrivers = [ "nvidia" ];
           15|   hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
             |                             ^
           16|   hardware.nvidia.prime = {
(use '--show-trace' to show detailed location information)
building Nix...
error: undefined variable 'config'

       at /etc/nixos/nvidia.nix:15:29:

           14|   services.xserver.videoDrivers = [ "nvidia" ];
           15|   hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
             |                             ^
           16|   hardware.nvidia.prime = {
(use '--show-trace' to show detailed location information)
building the system configuration...
error: undefined variable 'config'

       at /etc/nixos/nvidia.nix:15:29:

           14|   services.xserver.videoDrivers = [ "nvidia" ];
           15|   hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
             |                             ^
           16|   hardware.nvidia.prime = {
(use '--show-trace' to show detailed location information)

Is it a syntaxe error?

Ok, I put it on configuration.nix and it’s building :partying_face:

1 Like

Nice!

Nah, you just don’t have the config variable in scope.

All you’d need to do is add it to your module arguments, as you currently do in configuration.nix:

{ config, pkgs, ... }:

I wrote a long-form answer explaining module arguments the other day: Adding doom emacs using home manager - #2 by TLATER

1 Like

Haaaan, Okay! Thanks for explanations!

In any case, boom:

[eyome@nixos:~]$ nvidia-offload glxinfo -B
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 2048 MB
    Total available memory: 2048 MB
    Currently available dedicated video memory: 1944 MB
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: Quadro K1000M/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 470.182.03
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.6.0 NVIDIA 470.182.03
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)

OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 470.182.03
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

It works! Thank you!
If I have others issues with Lutris I’ll open another post, this one is already full and useful :grinning_face_with_smiling_eyes:

1 Like