71 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
{
 | 
						|
  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 = false;
 | 
						|
          powerManagement.finegrained = false;
 | 
						|
          # features not available for the old graphics card
 | 
						|
          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 = "575.51.02";
 | 
						|
            sha256_64bit = "sha256-XZ0N8ISmoAC8p28DrGHk/YN1rJsInJ2dZNL8O+Tuaa0=";
 | 
						|
            openSha256 = "sha256-NQg+QDm9Gt+5bapbUO96UFsPnz1hG1dtEwT/g/vKHkw=";
 | 
						|
            settingsSha256 = "sha256-6n9mVkEL39wJj5FB1HBml7TTJhNAhS/j5hqpNGFQE4w=";
 | 
						|
            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" ];
 | 
						|
}
 |