{
  lib,
  config,
  ...
}: let
  cfg = config.marleyos.hardware.nvidia;
in {
  options.marleyos.hardware.nvidia.enable = lib.mkEnableOption "nvidia";

  config = lib.mkIf cfg.enable {
    # NVIDIA drivers are unfree.
    nixpkgs.config.allowUnfree = lib.mkForce true;

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

    hardware = {
      # openGL.
      graphics.enable = true;

      nvidia = {
        modesetting.enable = true;
        nvidiaSettings = true;

        # Disable open-source drivers.
        open = false;
      };
    };
  };
}
