Add & Improve GPU profiles as well as hybrid ones

This commit is contained in:
Tyler Kelley 2024-01-27 01:03:09 -06:00
parent 43df512b8f
commit 3ed2a159a5
7 changed files with 98 additions and 1 deletions

View File

@ -17,5 +17,6 @@
inherit username; inherit wallpaperGit; })
(import ./../scripts/themechange.nix { inherit pkgs; inherit flakeDir; })
(import ./../scripts/theme-selector.nix { inherit pkgs; })
(import ./../scripts/nvidia-offload.nix { inherit pkgs; })
];
}

View File

@ -0,0 +1,9 @@
{ pkgs }:
pkgs.writeShellScriptBin "nvidia-offload" ''
export __NV_PRIME_RENDER_OFFLOAD=1
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only
exec "$@"
''

View File

@ -7,6 +7,8 @@
./boot.nix
./displaymanager.nix
./intel-gpu.nix
./intel-nvidia.nix
./nvidia.nix
./packages.nix
./polkit.nix
./services.nix

View File

@ -0,0 +1,52 @@
{ pkgs, config, lib, gpuType,
intel-bus-id, nvidia-bus-id, ... }:
lib.mkIf ("${gpuType}" == "intel-nvidia") {
nixpkgs.config.packageOverrides =
pkgs: {
vaapiIntel = pkgs.vaapiIntel.override {
enableHybridCodec = true;
};
};
# OpenGL
hardware.opengl = {
extraPackages = with pkgs; [
intel-media-driver
vaapiIntel
vaapiVdpau
libvdpau-va-gl
];
};
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
# Modesetting is required.
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
powerManagement.enable = false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.stable;
prime = {
offload = {
enable = true;
enableOffloadCmd = true;
};
# Make sure to use the correct Bus ID values for your system!
intelBusId = "${intel-bus-id}";
nvidiaBusId = "${nvidia-bus-id}";
};
};
}

27
config/system/nvidia.nix Normal file
View File

@ -0,0 +1,27 @@
{ pkgs, config, lib, gpuType, ... }:
lib.mkIf ("${gpuType}" == "nvidia") {
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
# Modesetting is required.
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
powerManagement.enable = false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.stable;
};
}

View File

@ -13,7 +13,7 @@ in {
environment.systemPackages = with pkgs; [
wget curl git cmatrix lolcat neofetch htop btop libvirt
polkit_gnome lm_sensors unzip unrar libnotify eza
v4l-utils ydotool wl-clipboard socat cowsay lsd
v4l-utils ydotool wl-clipboard socat cowsay lsd lshw
pkg-config meson hugo gnumake ninja go nodejs symbola
noto-fonts-color-emoji material-icons brightnessctl
toybox virt-viewer jetbrains.pycharm-community-bin

View File

@ -34,9 +34,15 @@
flakeDir = "/home/${username}/zaneyos";
# Driver selection profile
# Options include amd (tested), intel, nvidia
# GPU hybrid options: intel-nvidia, amd-nvidia
# vm for both if you are running a vm
cpuType = "amd";
gpuType = "amd";
# Run: sudo lshw -c display to find this info
# This is needed for hybrid nvidia offloading
# Run: nvidia-offload (insert program name)
intel-bus-id = "PCI:0:2:0";
nvidia-bus-id = "PCI:14:0:0";
pkgs = import nixpkgs {
inherit system;