44 lines
1.9 KiB
Nix
44 lines
1.9 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
|
|
let
|
|
name = "nvidia";
|
|
cfg = config.nixowos.${name};
|
|
in
|
|
{
|
|
options.nixowos.${name} = {
|
|
enable = lib.mkEnableOption name;
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
# enable nvidia drivers (not just for xorg!)
|
|
services.xserver.videoDrivers = [ "nvidia" ];
|
|
|
|
hardware.nvidia = lib.mkDefault {
|
|
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
|
|
# Enable this if you have graphical corruption issues or application crashes after waking
|
|
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
|
|
# of just the bare essentials.
|
|
powerManagement.enable = true;
|
|
# the following is from @tlater:matrix.tlater.net (Lix Off Topic, 2026-06-24)
|
|
# `powerManagement.enable` maps to this set of NVIDIA driver features: https://download.nvidia.com/XFree86/Linux-x86_64/610.43.02/README/powermanagement.html
|
|
# You can read through those docs yourself, but tl;dr: modern GPUs have more memory than can normally be stored on suspend, so they need a workaround.
|
|
# The modern open source drivers can use some cool kernel features that were behind the GPL lock beforehand to achieve that, the proprietary drivers are stuck with a hack. But basically, you always want to enable that option on NixOS.
|
|
# The `powermanagement.finegrained` stuff on the other hand has to do with multi-GPU setups. The two options should really not be grouped together like this.
|
|
|
|
# Use the NVidia open source kernel module (not to be confused with the
|
|
# independent third-party "nouveau" open source driver).
|
|
# Support is limited to the Turing and later architectures:
|
|
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
|
|
# Only available from driver 515.43.04+
|
|
open = true;
|
|
|
|
# Enable the Nvidia settings menu,
|
|
# accessible via `nvidia-settings`.
|
|
nvidiaSettings = true;
|
|
};
|
|
};
|
|
}
|