Need help to setup Nvidia/intel graphics

I really need help and guidance for setting up my system that is dell XPS 15 9510 model I9 11900H with 32Gb ram and intel uhd with rtx 3050 TI. I have managed to get working basic setup with all apps and stuff so I actually can use it but now comes the hard parts. I will post soon more specs when back on the laptop

{ config, pkgs, ... }:

{
  # -------------------------------------------------------------------
  # 1. SYSTEM-LEVEL IMPORTS (MODULES)
  # -------------------------------------------------------------------
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      # REMOVED: <home-manager/nixos>
    ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  # Use latest kernel.
  boot.kernelPackages = pkgs.linuxPackages_latest;

  boot.initrd.luks.devices."luks-8edb1b27-5162-4113-8d34-8b440a45ef52".device = "/dev/disk/by-uuid/8edb1b27-5162-4113-8d34-8b440a45ef52";
  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;

  # 2. Firewall Configuration (Recommended Security)
  networking.firewall.enable = true;
  # Allow SSH if you need to log in remotely (port 22)
  # networking.firewall.allowedTCPPorts = [ 22 ];
  # Log refused connections for debugging/security review
  networking.firewall.logRefusedConnections = true;

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

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

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

  # Enable the X11 windowing system.
  # You can disable this if you're only using the Wayland session.
  services.xserver.enable = true;

  # Enable the KDE Plasma Desktop Environment.
  services.displayManager.sddm.enable = true;
  services.desktopManager.plasma6.enable = true;

  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "fi";
    variant = "nodeadkeys";
  };

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

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  services.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.phatle = {
    isNormalUser = true;
    description = "Marko Jokinen";
    extraGroups = [ "networkmanager" "wheel" ];
    # All user packages previously defined in home.nix are now installed here:
    packages = with pkgs; [
      kdePackages.kate
      # kdePackages.neochat
      # Applications moved from home.nix:
      thunderbird
      blender
      darktable
      gimp
      inkscape
      steam
      libreoffice
      signal-desktop
      protonvpn-gui
      protonmail-bridge-gui
      proton-pass
    ];
  };

  # REMOVED: Section 3. HOME MANAGER CONFIGURATION

  # Install firefox.
  programs.firefox.enable = true;

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

  # Enable Zsh program features and add it to the list of available system shells
  environment.shells = with pkgs; [ zsh ];
  programs.zsh.enable = true;

  # Set Zsh as the default shell for all users
  users.defaultUserShell = pkgs.zsh;


  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    # wget
    # REMOVED: home-manager
    git
    nodejs
    zsh
  ];
  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  # 4. Nix Optimization and Garbage Collection
  nix = {
    # Set the Nix daemon to use maximum parallel build jobs
    settings = {
      max-jobs = "auto";
      cores = 0;
      # Automatically symlink duplicate files in the Nix store
      auto-optimise-store = true;
    };

    # Enable automatic garbage collection
    gc = {
      automatic = true;
      dates = "weekly"; # Run weekly
      # Keep generations only for the last 30 days
      options = "--delete-older-than 30d";
    };
  };

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = 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 = "25.11"; # Did you read the comment?

}

hardware-confuguration.nix

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "vmd" "nvme" "uas" "sd_mod" "rtsx_pci_sdmmc" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/mapper/luks-f1a43e56-d2f9-4b0e-9238-82b840993cc1";
      fsType = "ext4";
    };

  boot.initrd.luks.devices."luks-f1a43e56-d2f9-4b0e-9238-82b840993cc1".device = "/dev/disk/by-uuid/f1a43e56-d2f9-4b0e-9238-82b840993cc1";

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/7E07-FD8D";
      fsType = "vfat";
      options = [ "fmask=0077" "dmask=0077" ];
    };

  swapDevices =
    [ { device = "/dev/mapper/luks-8edb1b27-5162-4113-8d34-8b440a45ef52"; }
    ];

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

just ask more since i have no idea yet what i am doing

To take advantage of your NVIDIA GPU, try this:

configuration.nix

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

  hardware.nvidia = {
    open = false;
    modesetting.enable = true;

    prime = {
      # If you want to use an external monitor that's connected to your GPU,
      # then uncomment the option below. But it's best to start by leaving it disabled
      # to reduce complications.
      # offload.enable = true;

      # You've have to adjust these IDs by looking them up.
      # See https://nixos.wiki/wiki/Nvidia
      nvidiaBusId = "PCI:1:0:0";
      amdgpuBusId = "PCI:5:0:0";
    };
  };

hardware-configuration.nix

    boot.blacklistedKernelModules = [ "nouveau" "nvidiafb" ];

thanks something atleast happened, but not sure this is fully ready set for dual graphics, but atleast a start to something and seems i cant get cuda/nvidia-smi working need to tweak some more after reading docs

edit

got something now running on that atleast i have nvidia tools working and nvidia, but not sure if i have offload/hybrid setup yet, but this is progress and no cuda still since cuda is most important thing on my workflow so it is must to have

phatle@nixos:~/ > nvidia-smi
Mon Dec 15 05:38:14 2025       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.119.02             Driver Version: 580.119.02     CUDA Version: 13.0     |
+-----------------------------------------+------------------------+----------------------+
| 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 RTX 3050 ...    Off |   00000000:01:00.0 Off |                  N/A |
| N/A   50C    P3             14W /   35W |       0MiB /   4096MiB |      3%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
phatle@nixos:~/ > glxgears

okey i have opengl and cuda on some apps like Darktable it uses cuda and openGL, but some dont have like blender so that is just app issue now.

then i need to somehow monitor do i have offload working, but thank you all for help already slowly getting this and so much learning still

i cracked the system and got it working as hybrid with offloading thank you for help and point where to go and then just nix wiki and google made me do it

1 Like

What window manager is this? That configuration is definitely wrong for a 3050 TI, you should also fix yours @emmanuelrosa if you have the same hardware.

Seriously, I spend so much time fixing people’s nvidia configs, can we please stop recommending stuff without understanding what it does?

i am on plasma wayland and this is my config

# 5. Nvidia settings
  # Enable OpenGL hardware
  hardware.graphics.enable = true;

  # Load required video drivers
  services.xserver.videoDrivers = [ "modesetting" "nvidia" ];

  #specify open/closed source drivers
  hardware.nvidia.open = false;

  # Enable NVIDIA modesetting for better power management and performance
  hardware.nvidia.modesetting.enable = true;
  hardware.nvidia.powerManagement.enable = true;

  # Configure PRIME offload
  hardware.nvidia.prime = {
    offload.enable = true;
    # Use the correct Bus IDs for your system!
    intelBusId = "PCI:0:2:0"; # Example: adjust to your Intel/AMD iGPU ID
    nvidiaBusId = "PCI:1:0:0"; # Example: adjust to your Nvidia dGPU ID
  };  

and hardware config on nvidia side

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "vmd" "nvme" "uas" "sd_mod" "rtsx_pci_sdmmc" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];
  boot.blacklistedKernelModules = [ "nouveau" "nvidiafb" ];

  fileSystems."/" =
    { device = "/dev/mapper/luks-f1a43e56-d2f9-4b0e-9238-82b840993cc1";
      fsType = "ext4";
    };

  boot.initrd.luks.devices."luks-f1a43e56-d2f9-4b0e-9238-82b840993cc1".device = "/dev/disk/by-uuid/f1a43e56-d2f9-4b0e-9238-82b840993cc1";

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/7E07-FD8D";
      fsType = "vfat";
      options = [ "fmask=0077" "dmask=0077" ];
    };

  swapDevices =
    [ { device = "/dev/mapper/luks-8edb1b27-5162-4113-8d34-8b440a45ef52"; }
    ];

  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

not sure what is wrong with my setup since it works and it works as same as on openSuse, Fedora, Ubuntu etc first on intel gpu and offload ondemand to nvidia when needed

Things can “work” and be suboptimal or have long-term risks :slight_smile: That’s my issue with a lot of the cargo culting around nvidia, people have subtly broken or problematic configurations and often don’t find out for months.

Feel free to also read my related rant here; If nothing else, it’ll show you some of the pitfalls you may fall into. This is precisely why I said it’s not that easy in the other thread, by the way, there is a lot of misinformation around :wink:

nvidia configuration on NixOS, especially for laptops, is quite broken.

Ok, this means you’re among the lucky population for whom multi-GPU just happens to work out of the box; wayland compositors reuse whichever GPU was used during boot (the so-called “boot-vga”), and use that as the “primary” GPU.

Since this entirely depends on firmware behavior, BIOS configuration and firmware updates, as well as quite random things (like whether you have an external display connected or are on AC power), can affect the choice of this GPU. Some firmwares always choose the dGPU, like for example the firmware for the laptop in this thread.

For this reason I’d recommend actually configuring this the way you want, instead of relying on the firmware to make the correct choice, but let’s get to that after we clean up your configuration, because there’s a lot to be desired here also.


So let’s review:

Don’t set this. Your plasma module does this. It has nothing to do with nvidia, people are just cargo culting it because someone with a silly setup needs it and associated it with their graphics driver, and it’s been copy-pasted by people ever since.

Set this to just [ "nvidia" ]. The modesetting driver should be loaded by the kernel automatically since it isn’t blacklisted, and not placing nvidia at the top can cause issues.

This should be true for any post-Turing GPU. People set this to false if they don’t understand the difference between nouveau and nvidia or if they have an old GPU or if they copy-paste without thinking from someone to whom one of those two things applies.

Don’t set this, it’s the default, and force-setting default values prevents upstream maintenance.

This is actually mostly sensible, though the default is false. It’s technically an experimental feature of the nvidia driver, but it persists GPU memory for GPUs with more than 256MB of onboard memory during sleep. Without it, if you’re running something on your GPU that needs more memory (like, any game these days), you’ll wake your system to a black screen. Particularly impactful on laptops which you might put to sleep by closing the lid, especially in hybrid sleep mode (since suspend-to-ram shouldn’t run into issues here).

It is experimental, but I’ve rarely seen people have issues with it, so I recommend keeping it on. It’s useful to understand what it does, though, so you know what to try disabling if you run into issues with sleep.

This should be completely useless since you are on wayland, it literally only sets xserver configuration which you’re not using (well, xwayland kinda does, but I believe that your compositor controls the GPU even for xwayland windows - I have not yet verified this since I’ve focused on reusing this module in my past attempts at fixing the nvidia module).

You’re also missing some configuration that would allow your system to properly suspend the GPU when not in use, so currently you’re wasting about 20W of power continuously.


So, in a nutshell, I’d replace your configuration with this:

# nvidia.nix
#
# *Specifically* for a 3050 ti in a system with an iGPU; don't reuse
# blindly unless you know what you're doing.
{
  services.xserver.videoDrivers = [ "nvidia" ];

  hardware.nvidia = {
    open = true;
    powerManagement = {
      enable = true;
      # *Not* experimental, unlike `powerManagement.enable`, it has
      # nothing to do with sleep and it's actually broken by NixOS by
      # default; see my rant
      finegrained = true;
    };

    # You should at least try this with a PRIME setup
    dynamicBoost.enable = true;
  };
}

I’d also recommend putting this in a separate file (nvidia.nix as the comment says), and importing it in your configuration.nix’s imports, like hardware-configuration.nix. That just helps keep things separate.

While I’m at it, never play with the boot.kernelPackages option, as explained in my rant. If you want to prevent mistakes, or forgetting this in the future, add to the above nvidia.nix:

  assertions = lib.singleton {
    assertion =
      lib.strings.compareVersions config.boot.kernelPackages.kernel.version pkgs.linuxKernel.kernels.linux_default.version
      <= 0;
    message = "The nvidia driver can only support the LTS kernel.";
  };

You’ll also have to add { pkgs, config, lib, ... }: to the top of the module.

Caveat emptor: The nvidia driver is messy and this might not actually work or might have subtle bugs. I also don’t have a system with an intel GPU to test with, so I don’t know for sure if the modesetting driver behaves the same as amdgpu.

We may have to experiment a little, but in theory (according to the nvidia documentation) this is how your system should be configured - though we probably additionally want to force-set the primary GPU used by plasma once you’ve confirmed this works.

I don’t blame anyone for not having read the docs or experimented much, this driver is a PITA, but god do I wish people would stop assuming all setups can be configured the same, or that they know how it works just because they can get their system to boot.

thank you i actually tested your way settings and something really happened… everything broke and offloading didint work so i reverted for now back to old systems settings and will figure out where was the issues and why ti just did what it did. My laptop has always been wierd one when it comes to wayland and linux since always straight getting it working as shoul-ish atleast.

i think there is the correct way to get actually nvidia sleep and this all working as should, but now not yet other solution than my current working one, but i have time to figure these out with help of others

Fair enough! Not unexpected, but it’d be nice to know what exactly broke.

As I said:

But your config as-is is definitely not as intended by nvidia, and will burn more power than necessary.

offloading atleast and then when moved to nvidia.nix nothing worked even linked it even returned back to old on nvidia.nix and linked it just didint work, but when old on configuration.nix all works again.

this just might be something on my messy configs still at this moment and i havent even got home-manager yet working so that i can even use it, but that is another topic

if i remember i have had always need to use offload and always only working way has been this way where nvidia is “sleep”, but not fully sleep since intel and nvidia uses shared memory too so nvidia cant be fully sleep

Ok, there are a number of ways that could have been caused. It’s possible that amdgpu and the modesetting driver do actually behave completely differently as far as driver load ordering goes, but it’s also possible that removing the offload config just deletes the nvidia-offload script and you interpret that as “broken”.

When/if you have time and a more complete baseline, I’d appreciate it if you came back to debug that a little; I’d like to rewrite the upstream nvidia module (or at least offer a functional third party alternative), so having data from someone with an intel GPU is really helpful.

Feel free to DM me also, might be easier to do via chat/privately than here.

That’ll come down to how you imported the nix file, not the actual configuration, which I’d be happy to help with too if it comes to it.

yeah i will return to nvidia tweaking later basically after i get system basilined fully and then i have more time to start debugging what actually happened there so it might be week or longer, but i will send pm example when i have some more info what was going on if that is ok for you.
i am also on matrix daily, but i need to get working neochat for that first

1 Like