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

  # Allow to use the nvidia driver in the special case
  # Use in the boot menu
  specialisation = {
    nvidia-enabled = {
      configuration = {
        system.nixos.tags = [ "nvidia-enabled" ];
        # Enable OpenGL
        hardware.graphics.enable = lib.mkForce true;
        hardware.nvidia = lib.mkForce {
          modesetting.enable = true;
          powerManagement.enable = true;
          # features not available for the old graphics card
          powerManagement.finegrained = false;
          open = false;
          nvidiaSettings = false;

          prime = {
            sync.enable = true;
            nvidiaBusId = "PCI:1:0:0";
            intelBusId = "PCI:0:2:0";
          };

          package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
            version = "570.86.16"; # use new 570 drivers
            sha256_64bit = "sha256-RWPqS7ZUJH9JEAWlfHLGdqrNlavhaR1xMyzs8lJhy9U=";
            openSha256 = "sha256-DuVNA63+pJ8IB7Tw2gM4HbwlOh1bcDg2AN2mbEU9VPE=";
            settingsSha256 = "sha256-9rtqh64TyhDF5fFAYiWl3oDHzKJqyOW3abpcf2iNRT8=";
            usePersistenced = false;
          };

        };
        # overwrite the blacklists set previously
        boot.extraModprobeConfig = lib.mkForce "";
        boot.blacklistedKernelModules = lib.mkForce [];
        services.udev.extraRules = lib.mkForce "";
        services.xserver.videoDrivers = lib.mkForce ["nvidia"];
      };
    };
  };


  # In the global configuration, we blacklist the nouveau driver and load the nvidia driver
  boot.extraModprobeConfig = ''
    blacklist nouveau
    options nouveau modeset=0
  '';

  services.udev.extraRules = ''
    # Remove NVIDIA USB xHCI Host Controller devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1"
    # Remove NVIDIA USB Type-C UCSI devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1"
    # Remove NVIDIA Audio devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1"
    # Remove NVIDIA VGA/3D controller devices
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", ATTR{power/control}="auto", ATTR{remove}="1"
  '';

    # # Remove the whole bridge responsible for the VGA/3D controller
    # ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{class}=="0x060400", ATTR{power/control}="auto", ATTR{remove}="1"

  boot.blacklistedKernelModules = [ "nouveau" "nvidia" "nvidia_drm" "nvidia_modeset" ];
}
