{ config, lib, ... }:
{
  options.system.nvidia.enable = lib.mkEnableOption "Nvidia graphic drivers";

  config = lib.mkIf config.system.nvidia.enable {
    hardware.nvidia = {
      modesetting.enable = true;
      nvidiaSettings = false;
      open = true;
    };

    boot.kernelParams = [ "nvidia_drm.fbdev=1" ]; # Framebuffer fixes TTY access

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

    nixpkgs.allowUnfreePackages = [ "nvidia-x11" ];

    specialisation.nouveau.configuration.config.system.nvidia.enable = lib.mkForce false;
  };
}
