diff --git a/.config/i3/config b/.config/i3/config index 1554e43..be14f09 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -351,6 +351,7 @@ exec_always --no-startup-id sleep 5 && pactl list short sources | grep 'alsa_inp exec --no-startup-id /usr/bin/env dunst # alternative if you installed aside with XFCE4: # exec --no-startup-id /usr/lib/xfce4/notifyd/xfce4-notifyd & +exec --no-startup-id nvidia-settings -a "[gpu:0]/GPUGraphicsClockOffsetAllPerformanceLevels=230" # autotiling script # https://github.com/nwg-piotr/autotiling diff --git a/modules/hardware/nvidia.nix b/modules/hardware/nvidia.nix index e8a18f5..5107ecc 100644 --- a/modules/hardware/nvidia.nix +++ b/modules/hardware/nvidia.nix @@ -11,6 +11,21 @@ in { description = "The power limit to set the GPU to"; }; }; + clock = { + enable = lib.mkEnableOption "Set GPU clocks"; + min = lib.mkOption { + type = lib.types.int; + description = "The minimum GPU clock to set"; + }; + max = lib.mkOption { + type = lib.types.int; + description = "The maximum GPU clock to set"; + }; + offset = lib.mkOption { + type = lib.types.int; + description = "The GPU clock offset to set"; + }; + }; }; config = let @@ -88,9 +103,10 @@ in { libvdpau-va-gl libva libva-utils + (gwe.override { nvidia_x11 = config.hardware.nvidia.package; }) ]; - systemd.services.nvpl = lib.mkIf cfg.powerLimit.enable { + systemd.services.nvidiaSetPower = lib.mkIf cfg.powerLimit.enable { description = "Increase GPU power limit to ${toString cfg.powerLimit.wattage} watts"; script = "/run/current-system/sw/bin/nvidia-smi -pl=${ @@ -98,5 +114,26 @@ in { }"; wantedBy = [ "multi-user.target" ]; }; + systemd.services.nvidiaSetClocks = lib.mkIf cfg.clock.enable { + description = "Set GPU clocks"; + script = ''/run/current-system/sw/bin/nvidia-smi -i 0 -lgc ${toString cfg.clock.min},${toString cfg.clock.max}''; + wantedBy = [ "multi-user.target" ]; + after = [ "display-manager.service" ]; + requires = [ "display-manager.service" ]; + environment.DISPLAY = ":0"; + environment.XAUTHORITY = "/home/kopatz/.Xauthority"; + }; + systemd.user.services.nvidiaSetOffset = lib.mkIf cfg.clock.enable { + description = "Sets gpu offset"; + enable = true; + serviceConfig = { Type = "oneshot"; }; + script = '' + ${config.hardware.nvidia.package.settings}/bin/nvidia-settings -a "[gpu:0]/GPUGraphicsClockOffsetAllPerformanceLevels=${ + toString cfg.clock.offset + }"''; + environment = { DISPLAY = ":0"; }; + after = [ "xdg-desktop-autostart.target" ]; + wantedBy = [ "default.target" ]; + }; }); } diff --git a/systems/pc/configuration.nix b/systems/pc/configuration.nix index 67664ca..705a6f8 100644 --- a/systems/pc/configuration.nix +++ b/systems/pc/configuration.nix @@ -44,7 +44,12 @@ android.enable = true; nvidia = { enable = true; - powerLimit.enable = true; + clock = { + enable = true; + min = 210; + max = 1755; + offset = 230; + }; }; firmware.enable = true; ssd.enable = true;