Skip to content

Commit e8f38b2

Browse files
authored
Merge pull request #1414 from moduon/nvidia-battery-saver
feat(nvidia-prime): automatic battery-saver specialisation
2 parents c028fde + 33d083f commit e8f38b2

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

common/gpu/nvidia/prime.nix

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,35 @@
33
{
44
imports = [ ./. ];
55

6-
hardware.nvidia.prime = {
7-
offload = {
8-
enable = lib.mkOverride 990 true;
9-
enableOffloadCmd = lib.mkIf config.hardware.nvidia.prime.offload.enable true; # Provides `nvidia-offload` command.
6+
options = {
7+
hardware.nvidia.primeBatterySaverSpecialisation = lib.mkEnableOption "configure a specialisation which turns on NVIDIA Prime battery saver";
8+
};
9+
10+
config = {
11+
12+
hardware.nvidia.prime = {
13+
offload = {
14+
enable = lib.mkOverride 990 true;
15+
enableOffloadCmd = lib.mkIf config.hardware.nvidia.prime.offload.enable true; # Provides `nvidia-offload` command.
16+
};
17+
# Hardware should specify the bus ID for intel/nvidia devices
18+
};
19+
20+
specialisation = lib.mkIf config.hardware.nvidia.primeBatterySaverSpecialisation {
21+
battery-saver.configuration = {
22+
system.nixos.tags = ["battery-saver"];
23+
imports = [
24+
# Leave only the integrated GPU enabled
25+
./disable.nix
26+
];
27+
hardware.nvidia = {
28+
prime.offload.enable = lib.mkForce false;
29+
powerManagement = {
30+
enable = lib.mkForce false;
31+
finegrained = lib.mkForce false;
32+
};
33+
};
34+
};
1035
};
11-
# Hardware should specify the bus ID for intel/nvidia devices
1236
};
1337
}

0 commit comments

Comments
 (0)