so i’ve configured my nix with prime since my laptop has intel and nvidia GPU. but when i suspend and try to wake up. the screen is just black and i have to restart the laptop to make it work again.
this is how i configured my Prime
intel.nix
{pkgs, ...}: {
boot = {
initrd.kernelModules = ["i915"];
};
nixpkgs.config.packageOverrides = pkgs: {
# Avoid using intel-vaapi-driver for newer generations
intel-vaapi-driver = pkgs.intel-vaapi-driver.override {enableHybridCodec = false;};
};
hardware.graphics = {
# Use hardware.opengl for NixOS versions < 24.11
enable = true;
extraPackages = with pkgs; [
intel-media-driver # LIBVA_DRIVER_NAME=iHD
intel-vaapi-driver
libvdpau-va-gl # Optional for VDPAU support
libva-utils # Optional for VAAPI utilities
vpl-gpu-rt
];
};
}
nvidia.nix
{
config,
pkgs,
...
}: {
boot = {
initrd.kernelModules = ["nvidia" "nvidia_modeset" "nvidia_uvm" "nvidia_drm"];
kernelParams = [
"nvidia-drm.fbdev=1"
"nvidia.NVreg_PreserveVideoMemoryAllocations=1"
"acpi_backlight=video"
"nvidia.NVreg_EnableS0ixPowerManagement=0"
# "kvm.enable_virt_at_load=0"
];
};
environment.variables = {
# GBM_BACKEND = "nvidia-drm"; # If crash in firefox, remove this line
# LIBVA_DRIVER_NAME = "nvidia"; # hardware acceleration
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
NVD_BACKEND = "direct";
};
hardware = {
graphics = {
enable = true;
extraPackages = [pkgs.nvidia-vaapi-driver];
};
nvidia = {
# Modesetting is required.
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
# Enable this if you have graphical corruption issues or application crashes after waking
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
# of just the bare essentials.
powerManagement = {
enable = true;
};
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;
forceFullCompositionPipeline = true;
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.beta;
};
};
services.xserver.videoDrivers = ["nvidia" "displayLink" "vmware"];
}
prime.nix
{
hardware.nvidia = {
powerManagement = {
finegrained = true; # More precise power consumption control
};
prime = {
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
offload = {
enable = true;
enableOffloadCmd = true;
};
# Make the Intel iGP default. The NVIDIA Quadro is for CUDA/NVENC
# sync.enable = true;
};
};
}
also this what my is my output from pciutils
fathirbimashabri ~ ❯ nix-shell -p pciutils --run "lspci -nn | grep VGA"
0000:00:02.0 VGA compatible controller [0300]: Intel Corporation Alder Lake-P GT1 [UHD Graphics] [8086:46a3] (rev 0c)
0000:01:00.0 VGA compatible controller [0300]: NVIDIA Corporation AD107M [GeForce RTX 4060 Max-Q / Mobile] [10de:28a0] (rev a1)
fathirbimashabri ~ ❯ ls -l /dev/dri 18:38
drwxr-xr-x - root 5 Jan 18:28 by-path
crw-rw----@ 226,0 root 5 Jan 18:29 card0
crw-rw----@ 226,1 root 5 Jan 18:29 card1
crw-rw-rw- 226,128 root 5 Jan 18:28 renderD128
crw-rw-rw- 226,129 root 5 Jan 18:28 renderD129