Skip to content

Commit 5808a05

Browse files
committed
feat(nvidia-prime): automatic battery-saver specialisation
This enables a boot option that switches off NVIDIA GPU. Allows for battery saving. @moduon MT-9339
1 parent e1f1215 commit 5808a05

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

common/gpu/nvidia/prime.nix

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
{ lib, config, ... }:
22

33
{
4-
imports = [ ./. ];
4+
options = {
5+
hardware.nvidia.primeBatterySaverSpecialisation = lib.mkEnableOption "Enable the battery saver specialisation for NVIDIA Prime";
6+
};
7+
8+
config = {
9+
imports = [ ./. ];
10+
11+
hardware.nvidia.prime = {
12+
offload = {
13+
enable = lib.mkOverride 990 true;
14+
enableOffloadCmd = lib.mkIf config.hardware.nvidia.prime.offload.enable true; # Provides `nvidia-offload` command.
15+
};
16+
# Hardware should specify the bus ID for intel/nvidia devices
17+
};
518

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.
19+
# A specialisation for optimal battery life
20+
specialisation = lib.optionalAttrs 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.prime.offload.enable = lib.mkForce false;
28+
hardware.nvidia.powerManagement.enable = lib.mkForce false;
29+
hardware.nvidia.powerManagement.finegrained = lib.mkForce false;
30+
};
1031
};
11-
# Hardware should specify the bus ID for intel/nvidia devices
1232
};
1333
}

0 commit comments

Comments
 (0)