Nvidia-SMI and Nvidia-Settings Missing

Hello, I am new to NixOS and to Nix as a whole.

I have attempted to set up my laptop, which has an Intel integrated GPU and an Nvdia discrete GPU (an RTX 3060), correctly using various sources. However, it appears to have not worked; the only graphics card that I think is running is the Intel one.

Could you please help me find what I have done wrong?

Thanks.

Both GPUs are present
[ejb@ejb-dell:~]$ lspci | grep -e 'VGA'
00:02.0 VGA compatible controller: Intel Corporation Alder Lake-P GT2 [Iris Xe Graphics] (rev 0c)
01:00.0 VGA compatible controller: NVIDIA Corporation GA106M [GeForce RTX 3060 Mobile / Max-Q] (rev a1)
Prime offload attempt vs no prime offload
[ejb@ejb-dell:~]$ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep -e 'renderer'
    GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer, GLX_MESA_swap_control, 
    GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer, GLX_MESA_swap_control, 
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: Mesa Intel(R) Graphics (ADL GT2)

[ejb@ejb-dell:~]$ glxinfo | grep -e 'renderer'
    GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer, GLX_MESA_swap_control, 
    GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer, GLX_MESA_swap_control, 
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: Mesa Intel(R) Graphics (ADL GT2)

Here is my configuration.nix:

configuration.nix
{ config, pkgs, ... }:

{
  imports =
    [
      ./hardware-configuration.nix
    ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.initrd.kernelModules = [ "i915" ];
  boot.kernelParams = [
    "acpi_osi=Linux-Dell-Video" #I got this from some nixos-hardware module for a related laptop to my own (not the exact same, but it was the same line a couple of generations back, so it should work fine).
  ];

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

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

  networking.networkmanager.enable = true;

  #LOCALE INFO REMOVED FOR BREVITY

  #nix.settings.experimental-features = [ "nix-command" "flakes" ]; 

  #graphics
	
	services.thermald.enable = true;

	hardware.nvidia={
		prime = {
		offload = {
			enable = true;
			enableOffloadCmd = true;
		};
		# Make sure to use the correct Bus ID values for your system!
		intelBusId = "PCI:0:2:0";
		nvidiaBusId = "PCI:1:0:0";
		};
	modesetting.enable = true;
	powerManagement.finegrained = true;
	dynamicBoost.enable = true;
	open = false;
	nvidiaSettings = true;
	package = config.boot.kernelPackages.nvidiaPackages.beta;
	};
  
	hardware.opengl = {
	enable = true;
	driSupport = true;
	driSupport32Bit = true;
	};

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

  # Enable the XFCE Desktop Environment.
  services.xserver.displayManager.lightdm.enable = true;
  services.xserver.desktopManager.xfce.enable = true;

  # 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;
    #jack.enable = true;
    #media-session.enable = true;
  };

   services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.ejb = {
    isNormalUser = true;
    description = "ejb";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
	librewolf
    ];
  };

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

  # List packages installed in system profile. To search, run:
  # $ nix search wget

  environment.systemPackages = with pkgs;
    [
    git
    vim
    wget
    curl
    pciutils
    glxinfo
  ];

  environment.variables.EDITOR = "vim";


  system.stateVersion = "23.11";

}

PS: It has occurred to me that the Nvidia drivers themselves may be missing as well.

Yeah, you need to add the drivers with this: NixOS Search

Bit counterintuitive given hardware.nvidia.enable. There’s a pre-made module on nixos-hardware, if you need more pointers or want to outsource maintaining this part of your config (default + prime): https://github.com/NixOS/nixos-hardware/tree/master/common/gpu/nvidia

Thanks TLATER, that worked. I added the appropriate lines to my configuration, and all seems to be working as intended. I intend to outsource this once I understand Flakes properly, since that is less stateful than adding a nixos-hardware channel, if I understand correctly.

Working offload GLXInfo
[ejb@ejb-dell:~]$ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep -e 'renderer'
OpenGL renderer string: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2

[ejb@ejb-dell:~]$ glxinfo | grep -e 'renderer'
    GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer, GLX_MESA_swap_control, 
    GLX_MESA_copy_sub_buffer, GLX_MESA_query_renderer, GLX_MESA_swap_control, 
Extended renderer info (GLX_MESA_query_renderer):
OpenGL renderer string: Mesa Intel(R) Graphics (ADL GT2)

However, I wonder if I will need to create a specialisation with prime disabled if I boot my laptop with only the Nvidia graphics? (My laptop has a hardware multiplexer chip). If I find out I will edit this with an update for others wondering the same thing.
[Edit: Indeed, the system just shows a black screen when I boot it with only the Nvidia graphics (though dropping to tty works fine); I suppose I should create a specialisation disabling Prime.]

Thanks again.

1 Like