73 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 = true;
};
hardware.nvidia = {
prime = {
sync.enable = true;
# reverseSync.enable = true;
# allowExternalGpu = false;
nvidiaBusId = "PCI:1:0:0";
intelBusId = "PCI:0:2:0";
};
modesetting.enable = true;
powerManagement.enable = false;
powerManagement.finegrained = false;
open = false;
nvidiaSettings = false;
package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
version = "565.77"; # latest
sha256_64bit = "sha256-CnqnQsRrzzTXZpgkAtF7PbH9s7wbiTRNcM0SPByzFHw=";
sha256_aarch64 = "sha256-LSAYUnhfnK3rcuPe1dixOwAujSof19kNOfdRHE7bToE=";
openSha256 = "sha256-Fxo0t61KQDs71YA8u7arY+503wkAc1foaa51vi2Pl5I=";
settingsSha256 = "sha256-VUetj3LlOSz/LB+DDfMCN34uA4bNTTpjDrb6C6Iwukk=";
persistencedSha256 = "sha256-wnDjC099D8d9NJSp9D0CbsL+vfHXyJFYYgU3CwcqKww=";
};
};
boot.extraModprobeConfig = "";
boot.blacklistedKernelModules = [];
services.udev.extraRules = "";
services.xserver.videoDrivers = ["nvidia"];
};
};
};
# In the global configuration, we blacklist the nouveau driver and load the nvidia driver
boot.extraModprobeConfig = lib.mkDefault ''
blacklist nouveau
options nouveau modeset=0
'';
services.udev.extraRules = lib.mkDefault ''
# 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"
'';
boot.blacklistedKernelModules = lib.mkDefault [ "nouveau" "nvidia" "nvidia_drm" "nvidia_modeset" ];
}