Guanran Wang
4ad2ef60c0
with nvidia's latest driver (545.29.02), games behave extremely laggy when fps is not limited (for example. vsync is disabled) this commit temporarily reverts nvidia driver to version 470
50 lines
1.3 KiB
Nix
Executable file
50 lines
1.3 KiB
Nix
Executable file
{
|
|
lib,
|
|
config,
|
|
...
|
|
}: let
|
|
cfg = config.myFlake.nixos.hardware.gpu.nvidia;
|
|
in {
|
|
options = {
|
|
myFlake.nixos.hardware.gpu.nvidia.enable = lib.mkEnableOption "Whether to enable NVIDIA GPU.";
|
|
myFlake.nixos.hardware.gpu.nvidia.prime = lib.mkEnableOption "Whether to enable NVIDIA Prime.";
|
|
};
|
|
|
|
# https://nixos.wiki/wiki/Nvidia
|
|
config = lib.mkIf cfg.enable {
|
|
# Enable OpenGL
|
|
hardware.opengl = {
|
|
enable = true;
|
|
driSupport = true;
|
|
driSupport32Bit = true;
|
|
};
|
|
|
|
# Load nvidia driver for Xorg and Wayland
|
|
services.xserver.videoDrivers = ["nvidia"];
|
|
|
|
nixpkgs.config.nvidia.acceptLicense = true;
|
|
hardware.nvidia = {
|
|
package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
|
|
modesetting.enable = true;
|
|
};
|
|
|
|
# cfg.prime
|
|
hardware.nvidia.prime = lib.mkIf cfg.prime {
|
|
offload = {
|
|
enable = true;
|
|
enableOffloadCmd = true;
|
|
};
|
|
|
|
#sync.enable = true;
|
|
#reverseSync.enable = true;
|
|
|
|
### Device specific, please put those configuration in `machines/your-machine.nix`
|
|
# nvidiaBusId = "PCI:1:0:0";
|
|
# intelBusId = "PCI:0:2:0";
|
|
};
|
|
|
|
environment.sessionVariables = {
|
|
"GAMEMODERUNEXEC" = lib.mkIf (config.hardware.nvidia.prime.offload.enable || config.programs.gamemode.enable) "nvidia-offload"; # gamemode: nvidia offload
|
|
};
|
|
};
|
|
}
|