mirror of
https://github.com/zephrynis/nix-flake.git
synced 2026-02-18 12:11:54 +00:00
Fix: enhance NVIDIA configuration for improved performance and compatibility on desktop and laptop
This commit is contained in:
58
NVIDIA-SETUP.md
Normal file
58
NVIDIA-SETUP.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# NVIDIA Setup Notes
|
||||
|
||||
## Laptop Bus ID Configuration Required
|
||||
|
||||
**File to edit:** `/home/zeph/nix-flake/system/nvidia-laptop.nix`
|
||||
|
||||
### Steps:
|
||||
|
||||
1. Run this command on your **laptop**:
|
||||
```bash
|
||||
sudo lshw -c display
|
||||
```
|
||||
|
||||
2. Look for the `bus info` lines in the output:
|
||||
- **Intel GPU**: `bus info: pci@0000:00:02.0`
|
||||
- **NVIDIA GPU**: `bus info: pci@0000:01:00.0`
|
||||
|
||||
3. Convert the PCI addresses to NixOS format:
|
||||
- `pci@0000:00:02.0` → `PCI:0:2:0` (Intel)
|
||||
- `pci@0000:01:00.0` → `PCI:1:0:0` (NVIDIA)
|
||||
|
||||
4. Update the values in `nvidia-laptop.nix`:
|
||||
```nix
|
||||
intelBusId = "PCI:0:2:0"; # Replace with your Intel bus ID
|
||||
nvidiaBusId = "PCI:1:0:0"; # Replace with your NVIDIA bus ID
|
||||
```
|
||||
|
||||
5. Rebuild after updating:
|
||||
```bash
|
||||
sudo nixos-rebuild switch --flake /home/zeph/nix-flake#laptop
|
||||
```
|
||||
|
||||
### Format Conversion Example:
|
||||
```
|
||||
pci@0000:XX:YY.Z → PCI:XX:YY:Z
|
||||
```
|
||||
Remove the `0000:` prefix and convert the `.` to `:`
|
||||
|
||||
---
|
||||
|
||||
## Testing NVIDIA Setup
|
||||
|
||||
### Desktop (RTX 3080):
|
||||
- `nvidia-smi` - Check if driver is loaded
|
||||
- `nvtop` - Monitor GPU usage
|
||||
- `glxinfo | grep NVIDIA` - Verify OpenGL
|
||||
|
||||
### Laptop (GTX 1050):
|
||||
- `nvidia-smi` - Check if driver is loaded
|
||||
- `nvidia-offload glxgears` - Test offload mode
|
||||
- `nvtop` - Monitor both Intel and NVIDIA GPUs
|
||||
|
||||
### Using NVIDIA on Laptop:
|
||||
- Normal apps use Intel iGPU (better battery)
|
||||
- Prefix GPU-intensive apps with `nvidia-offload`:
|
||||
```bash
|
||||
nvidia-offload <program>
|
||||
```
|
||||
@@ -31,6 +31,15 @@
|
||||
"HYPRCURSOR_THEME,Bibata-Modern-Ice"
|
||||
"HYPRCURSOR_SIZE,24"
|
||||
"QT_QPA_PLATFORMTHEME,qt5ct"
|
||||
|
||||
# NVIDIA specific environment variables
|
||||
"LIBVA_DRIVER_NAME,nvidia" # Hardware acceleration
|
||||
"GBM_BACKEND,nvidia-drm" # Force GBM backend
|
||||
"__GLX_VENDOR_LIBRARY_NAME,nvidia" # GLX vendor
|
||||
"__GL_GSYNC_ALLOWED,1" # Enable G-Sync if supported
|
||||
"__GL_VRR_ALLOWED,0" # Disable VRR to avoid game issues
|
||||
"WLR_NO_HARDWARE_CURSORS,1" # Fix cursor issues on NVIDIA
|
||||
"WLR_DRM_NO_ATOMIC,1" # Legacy mode (try disabling if issues)
|
||||
];
|
||||
|
||||
# Input configuration
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
{ config, pkgs, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
../../system/nvidia.nix
|
||||
];
|
||||
|
||||
# Desktop PC specific configuration
|
||||
# RTX 3080 - Enable open-source kernel module for better performance
|
||||
hardware.nvidia.open = true;
|
||||
|
||||
networking.hostName = "zeph-desktop";
|
||||
|
||||
@@ -50,6 +56,11 @@
|
||||
# discord
|
||||
# steam
|
||||
# obs-studio
|
||||
|
||||
# NVIDIA utilities
|
||||
nvtopPackages.full # GPU monitoring tool
|
||||
vulkan-tools # Vulkan utilities (vulkaninfo, etc.)
|
||||
glxinfo # OpenGL information
|
||||
];
|
||||
|
||||
# Gaming support (uncomment if needed)
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
{ config, pkgs, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
../../system/nvidia-laptop.nix
|
||||
];
|
||||
|
||||
# Laptop specific configuration
|
||||
|
||||
networking.hostName = "zeph-laptop";
|
||||
@@ -65,6 +69,11 @@
|
||||
# Add laptop-specific packages here
|
||||
brightnessctl # Screen brightness control
|
||||
acpi # Battery info
|
||||
|
||||
# NVIDIA utilities
|
||||
nvtopPackages.full # GPU monitoring
|
||||
vulkan-tools # Vulkan utilities
|
||||
glxinfo # OpenGL info
|
||||
];
|
||||
|
||||
# Enable touchpad support
|
||||
|
||||
81
system/nvidia-laptop.nix
Normal file
81
system/nvidia-laptop.nix
Normal file
@@ -0,0 +1,81 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# NVIDIA Configuration for Laptop with Hybrid Graphics (Intel + GTX 1050)
|
||||
|
||||
# Enable OpenGL and NVIDIA drivers
|
||||
hardware.graphics = {
|
||||
enable = true;
|
||||
enable32Bit = true;
|
||||
};
|
||||
|
||||
# Load NVIDIA driver
|
||||
services.xserver.videoDrivers = [ "nvidia" ];
|
||||
|
||||
hardware.nvidia = {
|
||||
# Modesetting required for Wayland
|
||||
modesetting.enable = true;
|
||||
|
||||
# NVIDIA power management
|
||||
# Recommended for laptops to save battery
|
||||
powerManagement.enable = true;
|
||||
|
||||
# Fine-grained power management
|
||||
# Turns off GPU when not in use - EXPERIMENTAL
|
||||
# Can help with battery life but may cause issues
|
||||
powerManagement.finegrained = false;
|
||||
|
||||
# GTX 1050 is Pascal architecture - must use proprietary driver
|
||||
open = false;
|
||||
|
||||
# Enable nvidia-settings
|
||||
nvidiaSettings = true;
|
||||
|
||||
# Use stable driver
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
|
||||
# PRIME configuration for hybrid graphics
|
||||
prime = {
|
||||
# Offload mode: Intel for regular use, NVIDIA on-demand
|
||||
# This saves battery by keeping NVIDIA GPU off most of the time
|
||||
offload = {
|
||||
enable = true;
|
||||
enableOffloadCmd = true; # Adds nvidia-offload command
|
||||
};
|
||||
|
||||
# IMPORTANT: Find your actual Bus IDs with: sudo lshw -c display
|
||||
# Then update these values accordingly
|
||||
# Example output:
|
||||
# Intel: bus info: pci@0000:00:02.0 → intelBusId = "PCI:0:2:0"
|
||||
# NVIDIA: bus info: pci@0000:01:00.0 → nvidiaBusId = "PCI:1:0:0"
|
||||
|
||||
# Placeholder values - UPDATE THESE!
|
||||
intelBusId = "PCI:0:2:0"; # Usually correct for Intel iGPU
|
||||
nvidiaBusId = "PCI:1:0:0"; # Common for laptop discrete GPU
|
||||
|
||||
# Alternative: Use sync mode instead of offload
|
||||
# This runs everything on NVIDIA (worse battery, better performance)
|
||||
# Uncomment to enable:
|
||||
# sync.enable = true;
|
||||
# offload.enable = false; # Disable offload if using sync
|
||||
};
|
||||
};
|
||||
|
||||
# Kernel parameters for better NVIDIA support
|
||||
boot.kernelParams = [
|
||||
"nvidia-drm.modeset=1" # Required for Wayland
|
||||
];
|
||||
|
||||
# Create nvidia-offload command for easy GPU switching
|
||||
# Usage: nvidia-offload <program>
|
||||
# Example: nvidia-offload glxgears
|
||||
environment.systemPackages = with 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 "$@"
|
||||
'')
|
||||
];
|
||||
}
|
||||
62
system/nvidia.nix
Normal file
62
system/nvidia.nix
Normal file
@@ -0,0 +1,62 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# NVIDIA Driver Configuration for NixOS
|
||||
|
||||
# Enable OpenGL and NVIDIA drivers
|
||||
hardware.graphics = {
|
||||
enable = true;
|
||||
enable32Bit = true; # For 32-bit applications (games, Wine, etc.)
|
||||
};
|
||||
|
||||
# Load NVIDIA driver for Xorg and Wayland
|
||||
services.xserver.videoDrivers = [ "nvidia" ];
|
||||
|
||||
hardware.nvidia = {
|
||||
# Modesetting is required for Wayland
|
||||
modesetting.enable = true;
|
||||
|
||||
# Enable power management (experimental)
|
||||
# Helps with suspend/resume and may reduce power consumption
|
||||
powerManagement.enable = false;
|
||||
|
||||
# Fine-grained power management (turns off GPU when not in use)
|
||||
# Experimental and can cause sleep/suspend issues
|
||||
powerManagement.finegrained = false;
|
||||
|
||||
# Use the open source kernel module (not nouveau, but nvidia-open)
|
||||
# Only works on Turing and newer (RTX 20 series+, GTX 16 series+)
|
||||
# RTX 3080 supports this, but GTX 1050 does not
|
||||
# This can be overridden per-host
|
||||
open = false;
|
||||
|
||||
# Enable the Nvidia settings menu (nvidia-settings)
|
||||
nvidiaSettings = true;
|
||||
|
||||
# Select the appropriate driver version
|
||||
# Options: stable, beta, legacy_470, legacy_390, legacy_340
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
};
|
||||
|
||||
# Optional: For laptop with hybrid graphics (Intel/AMD + NVIDIA)
|
||||
# Uncomment the following lines if you have a hybrid setup:
|
||||
|
||||
# hardware.nvidia.prime = {
|
||||
# # Make sure to use the correct Bus ID values for your system!
|
||||
# # Find them with: sudo lshw -c display
|
||||
# offload = {
|
||||
# enable = true;
|
||||
# enableOffloadCmd = true;
|
||||
# };
|
||||
# # Bus ID of the Intel GPU (example)
|
||||
# intelBusId = "PCI:0:2:0";
|
||||
# # Bus ID of the NVIDIA GPU (example)
|
||||
# nvidiaBusId = "PCI:1:0:0";
|
||||
# };
|
||||
|
||||
# Kernel parameters
|
||||
boot.kernelParams = [
|
||||
# Uncomment if you experience issues:
|
||||
# "nvidia-drm.modeset=1"
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user