From 759c57dfac99860b1adbb628c5f41609a9ef6b45 Mon Sep 17 00:00:00 2001 From: Martin Berg Alstad Date: Sat, 11 Jan 2025 23:50:44 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=BA=20Reorganized,=20changed=20hardwar?= =?UTF-8?q?e=20acceleration=20to=20use=20Nvidia,=20added=20Nvidia=20powerm?= =?UTF-8?q?anagement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- home-manager/hyprland/settings.nix | 7 +++---- modules/hardware/graphics/default.nix | 13 +----------- modules/hardware/graphics/nvidia.nix | 29 ++++++++++++++++++++------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/home-manager/hyprland/settings.nix b/home-manager/hyprland/settings.nix index 3312aab..05893c0 100644 --- a/home-manager/hyprland/settings.nix +++ b/home-manager/hyprland/settings.nix @@ -13,16 +13,15 @@ in # Autostart exec-once = [ - "${app.browser}" - "${app.terminal}" + app.browser + app.terminal "hypridle" "systemctl --user start hyprpolkitagent" - # "waybar" "waypaper --restore" ]; env = [ - "ELECTRON_OZONE_PLATFORM_HINT,auto" + "ELECTRON_OZONE_PLATFORM_HINT,auto" # Tell Electron apps to use Wayland ]; general = { diff --git a/modules/hardware/graphics/default.nix b/modules/hardware/graphics/default.nix index 2712b6f..c2d26e4 100644 --- a/modules/hardware/graphics/default.nix +++ b/modules/hardware/graphics/default.nix @@ -1,19 +1,8 @@ -{ pkgs, ... }: - { imports = [ ./nvidia.nix ]; - # For hardware acceleration - environment.sessionVariables.LIBVA_DRIVER_NAME = "iHD"; - # Enable OpenGL - hardware.graphics = { - enable = true; - extraPackages = with pkgs; [ - # Used for hardware-acceleration - intel-media-driver # For Broadwell (2014) or newer processors. LIBVA_DRIVER_NAME=iHD - ]; - }; + hardware.graphics.enable = true; } diff --git a/modules/hardware/graphics/nvidia.nix b/modules/hardware/graphics/nvidia.nix index bb5c7e9..6b33ac2 100644 --- a/modules/hardware/graphics/nvidia.nix +++ b/modules/hardware/graphics/nvidia.nix @@ -1,11 +1,26 @@ +{ pkgs, ... }: + { - hardware.nvidia = { - # Required - modesetting.enable = true; - # Use closed-source drivers - open = false; - # Enable the Nvidia settings menu - nvidiaSettings = true; + boot.kernelParams = [ "nvidia.NVreg_PreserveVideoMemoryAllocations=1" ]; + + # For hardware acceleration + environment.sessionVariables.LIBVA_DRIVER_NAME = "nvidia"; + + hardware = { + graphics.extraPackages = with pkgs; [ + # Used for hardware-acceleration + nvidia-vaapi-driver + ]; + nvidia = { + # Required + modesetting.enable = true; + # Use closed-source drivers + open = false; + # Enable the Nvidia settings menu + nvidiaSettings = true; + # Enable nvidia-suspend.service, nvidia-hibernate.service and nvidia-resume.service + powerManagement.enable = true; + }; }; # Load Nvidia driver for Xorg and Wayland