Getting Help for Configuring Nvidia driver on NixOS 22.11

Hello everyone. I’m very new in NixOS ecosystem.
I want to configure Nvidia driver on my laptop, but I get confusing things in setup process. I inputted this configs in configuration.nix :

# Allow unfree packages
  nixpkgs.config.allowUnfree = true;
  
  # Configuring Nvidia PRIME
  hardware.nvidia.nvidiaSettings = true;
  services.xserver.videoDrivers = ["nvidia"];
  hardware.opengl.enable = true;
  hardware.nvidia.modesetting.enable = true;
  hardware.nvidia.prime = {
   offload.enable = true;

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

   # Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA
   intelBusId = "PCI:0:2:0";
  };
  hardware.opengl.driSupport32Bit = true;
  hardware.nvidia.powerManagement.enable = true;
  
  # Optionally, you may need to select the appropriate driver version for your specific GPU.
  hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;

But, Nvidia X Server Settings not showing GPU info and GNOME Settings can’t detect my GPU. I have comparisons from Fedora 37 (I dual boot with Fedora)

NixOS

Fedora 37

My questions is what should I do to solve this problem?
Thank you very much. Sorry My English

My NVIDIA settings GUI looks the same as yours, yet my GPU works.

Run nvidia-smi and see if Xorg (X11) is shown as one of the processes.

Then run __NV_PRIME_RENDER_OFFLOAD=1 glxinfo to check if offload rendering is working.

In the first case you are using wayland

Did you find the GPU with lspci as the config mentions? Can’t help but notice it’s the exact same bus ID as the ones from the wiki, I’ve not seen those repeated in the wild before.

Also, what laptop are you using? Have you checked GitHub - NixOS/nixos-hardware: A collection of NixOS modules covering hardware quirks. to see if someone has already configured your laptop before?

Lenovo Towers look to use this ids typically

Yes, same as you. In nvidia-smiI get a process

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 520.56.06    Driver Version: 520.56.06    CUDA Version: 11.8     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   37C    P8    N/A /  N/A |      3MiB /  2048MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1487      G   ...xorg-server-1.20.14/bin/X        2MiB |
+-----------------------------------------------------------------------------+

But, I haven’t glxinfo. How I install it? My inxi missed tools such as glxinfo

[anifyuli@X441UV:~]$ lspci
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Host Bridge/DRAM Registers (rev 08)
00:02.0 VGA compatible controller: Intel Corporation Skylake GT2 [HD Graphics 520] (rev 07)
00:04.0 Signal processing controller: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem (rev 08)
00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21)
00:14.2 Signal processing controller: Intel Corporation Sunrise Point-LP Thermal subsystem (rev 21)
00:15.0 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #0 (rev 21)
00:15.1 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO I2C Controller #1 (rev 21)
00:16.0 Communication controller: Intel Corporation Sunrise Point-LP CSME HECI #1 (rev 21)
00:17.0 SATA controller: Intel Corporation Sunrise Point-LP SATA Controller [AHCI mode] (rev 21)
00:1c.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #1 (rev f1)
00:1c.4 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #5 (rev f1)
00:1c.5 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #6 (rev f1)
00:1f.0 ISA bridge: Intel Corporation Sunrise Point-LP LPC Controller (rev 21)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21)
00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
01:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 920MX] (rev a2)
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL810xE PCI Express Fast Ethernet controller (rev 07)
03:00.0 Network controller: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter (rev 01)

I think I have mistakes after checking lspci. I will try to change it immediately.
For nixos-hardware, my laptop or family types of my laptop (such as VivoBook, UltraBook, TUF, etc) is not listed on here. Only ROG series in here

I use Xorg or Wayland only get it in my NixOS setup

You can get glxinfo with nix-shell -p glxinfo

Okay, I will write it on configs

I edit my configs following lspci result, and executing __NV_PRIME_RENDER_OFFLOAD=1 glxinfo, but it’s not changing anything.

What should I do again?

What does nvidia-smi show?

Based on a prior post, it looks like you had offload rendering configured correctly at some point.

You can read my recent reply. I ask to you how to install glxinfo and I post my nvidia-smi value

If you are indeed using render offload and it appears that you are, then nvidia-settings doesn’t show anything currently. I opened a ticket for this a while back:
https://github.com/NixOS/nixpkgs/issues/187543

I anecdotally remember it working before, but it could just be a faulty memory. Unfortunatly I have no idea how to debug further, but the good news is that most functionality of your GPU should work, you just won’t see any information about it in the nvidia-settings GUI.

Thanks, Mister for forwarding to NixOS issue repos. So better conclusion from my problem is waiting for this problem fixed?

Well you don’t have to wait to actually use your GPU, since it works properly with render offload. You just won’t see any information about it in the nvidia-settings GUI until this is fixed. You can still view information abou the GPU and apps it currently has loaded with nvidia-smi as mentioned.

So, can I install switchheroo-control to launch apps with Nvidia GPU?

I dunno, I’ve never used that particular program. But I believe newer versions of gnome have a built in “launch with dGPU” option in the context menu (right-click).

There are a few environmental variables you can set to manually launch any program with the dGPU as well. There is a small little script for accomplishing that outlined in the wiki:
https://nixos.wiki/wiki/Nvidia#Nvidia_PRIME