1
0
mirror of https://github.com/XNM1/linux-nixos-hyprland-config-dotfiles.git synced 2025-09-15 09:45:58 +03:00

added opengl and nvidia configs

This commit is contained in:
xnm
2024-04-21 21:58:07 +03:00
parent 82f6e30389
commit 1451a6c90e
4 changed files with 132 additions and 0 deletions

21
nixos/disable-nvidia.nix Normal file
View File

@@ -0,0 +1,21 @@
{ ... }:
{
boot.extraModprobeConfig = ''
blacklist nouveau
options nouveau modeset=0
'';
services.udev.extraRules = ''
# Remove NVIDIA USB xHCI Host Controller devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA USB Type-C UCSI devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA Audio devices, if present
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1"
# Remove NVIDIA VGA/3D controller devices
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
'';
boot.blacklistedKernelModules = [ "nouveau" "nvidia" "nvidia_drm" "nvidia_modeset" ];
}

View File

@@ -13,6 +13,9 @@
modules = [
./configuration.nix
./hardware-configuration.nix
# ./nvidia.nix
# ./disable-nvidia.nix
./opengl.nix
# ./fingerprint-scanner.nix
./yubikey.nix
./sound.nix

76
nixos/nvidia.nix Normal file
View File

@@ -0,0 +1,76 @@
{ config, lib, ... }:
{
# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
# Modesetting is required.
modesetting.enable = true;
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
# Enable this if you have graphical corruption issues or application crashes after waking
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
# of just the bare essentials.
powerManagement.enable = true;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = true;
# 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 = true;
# 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.production;
# Nvidia Optimus PRIME. It is a technology developed by Nvidia to optimize
# the power consumption and performance of laptops equipped with their GPUs.
# It seamlessly switches between the integrated graphics,
# usually from Intel, for lightweight tasks to save power,
# and the discrete Nvidia GPU for performance-intensive tasks.
prime = {
offload = {
enable = true;
enableOffloadCmd = true;
};
# FIXME: Change the following values to the correct Bus ID values for your system!
# More on "https://wiki.nixos.org/wiki/Nvidia#Configuring_Optimus_PRIME:_Bus_ID_Values_(Mandatory)"
nvidiaBusId = "PCI:0:0:0";
intelBusId = "PCI:0:0:0";
};
};
# NixOS specialization named 'nvidia-sync'. Provides the ability
# to switch the Nvidia Optimus Prime profile
# to sync mode during the boot process, enhancing performance.
specialisation = {
nvidia-sync.configuration = {
system.nixos.tags = [ "nvidia-sync" ];
hardware.nvidia = {
powerManagement.finegrained = lib.mkForce false;
prime.offload.enable = lib.mkForce false;
prime.offload.enableOffloadCmd = lib.mkForce false;
prime.sync.enable = lib.mkForce true;
# Dynamic Boost. It is a technology found in NVIDIA Max-Q design laptops with RTX GPUs.
# It intelligently and automatically shifts power between
# the CPU and GPU in real-time based on the workload of your game or application.
dynamicBoost.enable = lib.mkForce true;
};
};
};
}

32
nixos/opengl.nix Normal file
View File

@@ -0,0 +1,32 @@
{ pkgs, ... }:
{
nixpkgs.config.packageOverrides = pkgs: {
intel-vaapi-driver = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; };
};
# Enable OpenGL
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
extraPackages = with pkgs; [
intel-compute-runtime
intel-media-driver # LIBVA_DRIVER_NAME=iHD
intel-vaapi-driver # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
vaapiVdpau
libvdpau-va-gl
mesa
nvidia-vaapi-driver
nv-codec-headers-12
];
extraPackages32 = with pkgs.pkgsi686Linux; [
intel-media-driver
intel-vaapi-driver
vaapiVdpau
mesa
libvdpau-va-gl
];
};
}