OpenGL running on the iGPU insted of dGPU

I am a beginner in NixOS, and my configuration is practically the default one (link). The only difference is that I have a shell script before the configuration to set up a command for offloading. I am using an Acer Nitro 5 with the following specs:

OS: NixOS 23.11.3376.1b64fc128799 (Tapir) x86_64 
 Host: KBL Freed_KLS 
 Kernel: 6.1.74 
Uptime: 20 mins 
Packages: 736 (nix-system), 605 (nix-user) 
Shell: bash 5.2.15 
Resolution: 1920x1080, 1920x1080 
DE: none+qtile 
WM: LG3D 
Theme: Adwaita [GTK3] 
Icons: Adwaita [GTK3] 
Terminal: .terminator-wra 
CPU: Intel i7-7700HQ (8) @ 2.800GHz 
GPU: Intel HD Graphics 630 
 GPU: NVIDIA GeForce GTX 1050 Ti Mobile 
 Memory: 2193MiB / 15891MiB 

For my Nvidia GPU, I set it up as suggested on the wiki using the offload suggestion. This works great because the dGPU stays quiet and sleeps, only running the X11. When I want to run something on it, I just use a command like “nvidia-offload krita.”

The problem I’m having is that OpenGL is running on the iGPU (Intel), and I would like it to run on the Nvidia as default on. However, I’m not sure how I can achieve that. Has anybody tried this before?

I failed to mention that if I execute the command
glxinfo | grep 'OpenGL', it will display

OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) HD Graphics 630 (KBL GT2)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 23.1.9
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6 (Compatibility Profile) Mesa 23.1.9
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 Mesa 23.1.9
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

However, if I run the command nvidia-offload glxinfo | grep 'OpenGL', it will show

 OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: NVIDIA GeForce GTX 1050 Ti/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 545.29.02
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6.0 NVIDIA 545.29.02
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 545.29.02
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

Therefore, it’s not that OpenGL is not running correctly; rather, I would like to configure it to run on the dGPU by default.

Try this:

services.xserver.videoDrivers = [
  "nvidia"
];

Or perhaps:

services.xserver.videoDrivers = [
  "nvidia"
  "intel"
];

Hi, thanks for the suggestion.
The first option reflects my configuration, and the second option was one of my attempts. However, it causes X11 to fail during OS startup, leaving me without a graphical interface.

1 Like

Have you tried also the nvidiaLegacy* drivers?

Yes. When I first started setting up my NixOS and reached the Nvidia setup, I checked the legacy list, and the GTX 1050 Ti does not fall into that category.