{ pkgs, ... }:

{
  boot.kernelParams = [ "nvidia.NVreg_PreserveVideoMemoryAllocations=1" ];

  # For hardware acceleration
  environment.sessionVariables.LIBVA_DRIVER_NAME = "nvidia";

  hardware = {
    graphics.extraPackages = with pkgs; [
      # Used for hardware-acceleration
      nvidia-vaapi-driver
    ];
    nvidia = {
      # Required
      modesetting.enable = true;
      # Use closed-source drivers
      open = false;
      # Enable the Nvidia settings menu
      nvidiaSettings = true;
      # Enable nvidia-suspend.service, nvidia-hibernate.service and nvidia-resume.service
      powerManagement.enable = true;
    };
  };

  # Load Nvidia driver for Xorg and Wayland
  services.xserver.videoDrivers = [ "nvidia" ];
}
