{ config, pkgs, lib, prefs, ... }:

{
  options.modules.nvidia.enable = lib.mkEnableOption "Enable NVIDIA kernel and modprobe configurations.";

  config = lib.mkIf config.modules.nvidia.enable {
    boot.kernelPackages = pkgs.linuxPackages_6_1; # LTS
    services.xserver.videoDrivers = [ "nvidia" ];

    hardware.nvidia = {
      modesetting.enable = true;
      powerManagement.enable = true;
      prime = {
        sync.enable = true;
        intelBusId = prefs.hosts.hulk.intelBusId;
        nvidiaBusId = prefs.hosts.hulk.nvidiaBusId;
      };

      nvidiaSettings = true;
      package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
    };
  };
}
