I have igpu as amd and dgpu as nvidia why my system using dgpu
Here is my Nix Nvidia config
Because you’re using wayland and the hardware.nvidia.prime module is completely useless on wayland. On wayland, the GPU that your firmware chooses early during boot will be used. In general, hardware.nvidia is pretty broken, but there doesn’t seem to be much interest in fixing it.
You might be able to change that in the BIOS settings, but IMO the more reliable way is to use compositor-specific features to choose the primary GPU. For KDE, that’s the For wlroots, that’s the KWIN_DRM_DEVICES variableWLR_DRM_DEVICES variable - I think niri uses that. Unfortunately you have to do some messy udev rule stuff to create symlinks for your GPUs and use that variable, since it splits on : and PCI paths include :.
While I’m at it, I recommend removing ALL of the configuration in the first screenshot and replacing it with just this:
# Needed for niri because the upstream module forgets to set it;
# besides enabling `hardware.graphics.enable`, it also enables a
# lot of other important things:
#
# https://github.com/NixOS/nixpkgs/blob/0a29f5712c0125ef21b26ae16a76a3ef9dc19294/nixos/modules/services/misc/graphical-desktop.nix#L23
#
# TODO: You might want to create a PR to fix this upstream ;)
services.graphical-desktop.enable = true;
hardware.nvidia = {
open = true;
powerManagement = {
enable = true;
finegrained = true;
};
};
If you want to, you can also try out hardware.nvidia.dynamicBoost.enable and see if it improves performance or battery life; on laptops with iGPU+dGPU setups that feature actually works.