diff options
author | Gerg-L <GregLeyda@proton.me> | 2023-07-17 17:17:29 -0400 |
---|---|---|
committer | Gerg-L <GregLeyda@proton.me> | 2023-08-03 09:32:14 -0400 |
commit | 4ca2a16390d73d68d4262a45d892ffab6e28f6bc (patch) | |
tree | 383edbe503da8835bfa8147eed9a872187f1db91 | |
parent | a5ccd2c5c8a0610cfe8fab09a7fb67b40c4c1313 (diff) | |
download | nixpkgs-4ca2a16390d73d68d4262a45d892ffab6e28f6bc.tar nixpkgs-4ca2a16390d73d68d4262a45d892ffab6e28f6bc.tar.gz nixpkgs-4ca2a16390d73d68d4262a45d892ffab6e28f6bc.tar.bz2 nixpkgs-4ca2a16390d73d68d4262a45d892ffab6e28f6bc.tar.lz nixpkgs-4ca2a16390d73d68d4262a45d892ffab6e28f6bc.tar.xz nixpkgs-4ca2a16390d73d68d4262a45d892ffab6e28f6bc.tar.zst nixpkgs-4ca2a16390d73d68d4262a45d892ffab6e28f6bc.zip |
nixos/nvidia: add Dynamic Boost support
-rw-r--r-- | nixos/modules/hardware/video/nvidia.nix | 27 | ||||
-rwxr-xr-x | pkgs/os-specific/linux/nvidia-x11/builder.sh | 5 | ||||
-rw-r--r-- | pkgs/os-specific/linux/nvidia-x11/generic.nix | 1 |
3 files changed, 32 insertions, 1 deletions
diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix index eef85953a91..67c3afcf320 100644 --- a/nixos/modules/hardware/video/nvidia.nix +++ b/nixos/modules/hardware/video/nvidia.nix @@ -31,6 +31,12 @@ in { the NVIDIA docs, on Chapter 22. PCI-Express Runtime D3 (RTD3) Power Management. ''); + dynamicBoost.enable = lib.mkEnableOption (lib.mdDoc '' + dynamic Boost balances power between the CPU and the GPU for improved + performance on supported laptops using the nvidia-powerd daemon. For more + information, see the NVIDIA docs, on Chapter 23. Dynamic Boost on Linux. + ''); + modesetting.enable = lib.mkEnableOption (lib.mdDoc '' kernel modesetting when using the NVIDIA proprietary driver. @@ -238,6 +244,11 @@ in { assertion = cfg.open -> (cfg.package ? open && cfg.package ? firmware); message = "This version of NVIDIA driver does not provide a corresponding opensource kernel driver"; } + + { + assertion = cfg.dynamicBoost.enable -> lib.versionAtLeast nvidia_x11.version "510.39.01"; + message = "NVIDIA's Dynamic Boost feature only exists on versions >= 510.39.01"; + } ]; # If Optimus/PRIME is enabled, we: @@ -394,10 +405,26 @@ in { }; }; }) + (lib.mkIf cfg.dynamicBoost.enable { + "nvidia-powerd" = { + description = "nvidia-powerd service"; + path = [ + pkgs.util-linux # nvidia-powerd wants lscpu + ]; + wantedBy = ["multi-user.target"]; + serviceConfig = { + Type = "dbus"; + BusName = "nvidia.powerd.server"; + ExecStart = "${nvidia_x11.bin}/bin/nvidia-powerd"; + }; + }; + }) ]; services.acpid.enable = true; + services.dbus.packages = lib.optional cfg.dynamicBoost.enable nvidia_x11.bin; + hardware.firmware = lib.optional cfg.open nvidia_x11.firmware; systemd.tmpfiles.rules = diff --git a/pkgs/os-specific/linux/nvidia-x11/builder.sh b/pkgs/os-specific/linux/nvidia-x11/builder.sh index 2b0f55c0387..07a9961a1ba 100755 --- a/pkgs/os-specific/linux/nvidia-x11/builder.sh +++ b/pkgs/os-specific/linux/nvidia-x11/builder.sh @@ -196,9 +196,12 @@ installPhase() { mkdir -p $bin/share/man/man1 cp -p *.1.gz $bin/share/man/man1 rm -f $bin/share/man/man1/{nvidia-xconfig,nvidia-settings,nvidia-persistenced}.1.gz + if [ -e "nvidia-dbus.conf" ]; then + install -Dm644 nvidia-dbus.conf $bin/share/dbus-1/system.d/nvidia-dbus.conf + fi # Install the programs. - for i in nvidia-cuda-mps-control nvidia-cuda-mps-server nvidia-smi nvidia-debugdump; do + for i in nvidia-cuda-mps-control nvidia-cuda-mps-server nvidia-smi nvidia-debugdump nvidia-powerd; do if [ -e "$i" ]; then install -Dm755 $i $bin/bin/$i # unmodified binary backup for mounting in containers diff --git a/pkgs/os-specific/linux/nvidia-x11/generic.nix b/pkgs/os-specific/linux/nvidia-x11/generic.nix index 2571812b964..792fda42ca9 100644 --- a/pkgs/os-specific/linux/nvidia-x11/generic.nix +++ b/pkgs/os-specific/linux/nvidia-x11/generic.nix @@ -51,6 +51,7 @@ let libdrm xorg.libXext xorg.libX11 xorg.libXv xorg.libXrandr xorg.libxcb zlib stdenv.cc.cc wayland mesa libGL openssl + dbus # for nvidia-powerd ]); self = stdenv.mkDerivation { |