mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-06 01:38:06 +00:00
[Hardware/Nvidia] Fix suspend with Nvidia GPUs
This commit is contained in:
parent
f4f6600ec5
commit
04cfbf21a4
2 changed files with 11 additions and 5 deletions
|
|
@ -8,12 +8,12 @@ in {
|
|||
./vgpu.nix
|
||||
./proprietary.nix
|
||||
./opensource.nix
|
||||
( mkRenamedOptionModule [ "aviallon" "hardware" "nvidia" "saveAllVram" ] [ "aviallon" "hardware" "nvidia" "proprietary" "saveAllVram" ] )
|
||||
];
|
||||
|
||||
options.aviallon.hardware.nvidia = {
|
||||
enable = mkEnableOption "enable Nvidia hardware config";
|
||||
useProprietary = mkEnableOption "nvidia proprietary drivers";
|
||||
saveAllVram = mkEnableOption "back up all VRAM in /tmp before going to sleep. May reduce artifacts after resuming";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
|
|
|||
|
|
@ -21,10 +21,14 @@ in {
|
|||
example = 28;
|
||||
type = types.int;
|
||||
};
|
||||
saveAllVram = mkEnableOption "back up all VRAM in /var/tmp before going to sleep. May reduce artifacts after resuming";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable && cfg.useProprietary) {
|
||||
|
||||
assertions = [];
|
||||
|
||||
boot.initrd.kernelModules = [
|
||||
"nvidia"
|
||||
"nvidia_drm"
|
||||
|
|
@ -44,8 +48,10 @@ in {
|
|||
services.xserver.exportConfiguration = true;
|
||||
|
||||
hardware.nvidia = {
|
||||
powerManagement.enable = true;
|
||||
powerManagement.finegrained = mkIf config.hardware.nvidia.prime.offload.enable true;
|
||||
powerManagement = mkIf (config.hardware.nvidia.prime.offload.enable || cfg.proprietary.saveAllVram) {
|
||||
enable = true;
|
||||
finegrained = true;
|
||||
};
|
||||
modesetting.enable = true;
|
||||
nvidiaSettings = true;
|
||||
};
|
||||
|
|
@ -55,8 +61,8 @@ in {
|
|||
"nvidia-drm.modeset" = 1;
|
||||
"nvidia.NVreg_UsePageAttributeTable" = 1;
|
||||
}
|
||||
// optionalAttrs cfg.saveAllVram {
|
||||
"nvidia.NVreg_PreserveVideoMemoryAllocations" = 1;
|
||||
// {
|
||||
"nvidia.NVreg_PreserveVideoMemoryAllocations" = toValue cfg.proprietary.saveAllVram;
|
||||
"nvidia.NVreg_TemporaryFilePath" = "/var/tmp/nvidia-gpu.vram.img";
|
||||
}
|
||||
;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue