give me the must have config for mi nixos laptop, it has a moder interl cpu and a nvidia…
- User
give me the must have config for mi nixos laptop, it has a moder interl cpu and a nvidia 3080ti gpu, i want good performance, long lasting battery and of course, stability and features
Assistant
Here's a comprehensive NixOS configuration for your Intel/NVIDIA laptop focusing on performance, battery life, and stability. Key features include proper NVIDIA Optimus setup, power management, and stability enhancements:
{ config, pkgs, ... }: { imports = [ <nixpkgs/nixos/modules/installer/scan/not-detected.nix> ]; # Kernel and Boot boot = { kernelModules = [ "kvm-intel" "nvidia" "acpi_call" ]; extraModulePackages = with config.boot.kernelPackages; [ nvidia_x11 acpi_call ]; kernelParams = [ "intel_iommu=on" "i915.enable_fbc=1" "i915.enable_guc=2" "nvidia-drm.modeset=1" ]; # Use latest LTS kernel for stability kernelPackages = pkgs.linuxPackages_latest; blacklistedKernelModules = [ "nouveau" ]; }; # NVIDIA Configuration hardware = { nvidia = { modesetting.enable = true; powerManagement = { enable = true; finegrained = true; # Better power management for Turing+ GPUs }; prime = { offload = { enable = true; enableOffloadCmd = true; }; intelBusId = "PCI:0:2:0"; nvidiaBusId = "PCI:1:0:0"; }; package = config.boot.kernelPackages.nvidiaPackages.stable; # 545.x for 23.11 }; opengl = { enable = true; driSupport = true; driSupport32Bit = true; extraPackages = with pkgs; [ intel-media-driver vaapiIntel vaapiVdpau libvdpau-va-gl ]; extraPackages32 = with pkgs.pkgsi686Linux; [ vaapiIntel ]; }; }; # Power Management powerManagement = { enable = true; powertop.enable = true; cpuFreqGovernor = "powersave"; }; services = { tlp = { enable = true; settings = { CPU_SCALING_GOVERNOR_ON_AC = "performance"; CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; PCIE_ASPM_ON_BAT = "powersupersave"; RADEON_DPM_STATE_ON_BAT = "battery"; PLATFORM_PROFILE_ON_AC = "performance"; PLATFORM_PROFILE_ON_BAT = "low-power"; NMI_WATCHDOG = 0; }; }; auto-cpufreq.enable = true; thermald.enable = true; }; # CPU-specific optimizations environment.etc."sysctl.d/99-cpu.conf".text = '' dev.i915.perf_stream_paranoid=0 kernel.nmi_watchdog=0 ''; # Essential packages environment.systemPackages = with pkgs; [ nvtop intel-gpu-tools acpi powertop auto-cpufreq vdpauinfo glxinfo ]; # GPU offloading wrapper environment.sessionVariables = { NIXOS_OZONE_WL = "1"; LIBVA_DRIVER_NAME = "iHD"; }; # Enable early KMS services.xserver = { enable = true; videoDrivers = [ "nvidia" ]; displayManager.setupCommands = '' ${pkgs.xorg.xrandr}/bin/xrandr --setprovideroutputsource modesetting NVIDIA-0 --auto ''; }; # Battery optimizations systemd.services."battery-optimizations" = { description = "Battery saving tweaks"; wantedBy = [ "multi-user.target" ]; script = '' echo 1 > /sys/module/snd_hda_intel/parameters/power_save echo 5 > /proc/sys/vm/laptop_mode ''; serviceConfig.Type = "oneshot"; }; # Hardware-specific settings nixpkgs.config.allowUnfree = true; system.stateVersion = "23.11"; # Keep when upgrading }Key Features Explained:
-
GPU Configuration:
- PRIME offloading for hybrid graphics (run apps with
__NV_PRIME_RENDER_OFFLOAD=1) - Proper Bus IDs for Intel/NVIDIA devices
- NVIDIA power management with fine-grained control
- VA-API/VDPAU video acceleration
- PRIME offloading for hybrid graphics (run apps with
-
Power Saving:
- TLP with battery/AC profiles
- Auto-cpufreq for dynamic scaling
- Powertop auto-tune
- Intel GPU power saving flags
- Aggressive ASPM and PCIe power saving
-
Performance Tweaks:
- Intel GUC firmware loading (enable GuC/HuC)
- Latest stable kernel with proper microcode
- CPU governor optimizations
- Thermal daemon for heat management
-
Stability Enhancements:
- Latest LTS kernel
- Disabled problematic nouveau
- Early KMS initialization
- Intel IOMMU enabled
- Blacklisted unstable modules
Post-Install Steps:
-
Verify GPU offloading:
glxinfo | grep "OpenGL renderer" __NV_PRIME_RENDER_OFFLOAD=1 glxinfo | grep "OpenGL renderer" -
Check video acceleration:
vdpauinfo vainfo -
Monitor power usage:
powertop nvtop -
Enable services:
sudo systemctl enable tlp thermald auto-cpufreq
Important Notes:
-
Adjust
intelBusId/nvidiaBusIdusing:lspci | grep -E "VGA|3D" -
For Wayland support:
- Add
nvidia.modesetting.waylandCompositorFix = true; - Use GNOME or KDE Plasma
- Add
-
Battery life tips:
- Use
auto-cpufreq --monitor - Switch to Intel GPU only when not gaming:
prime-offload - Consider
nvidia-smi --persistence-mode=0
- Use
This configuration balances performance and battery life while maintaining stability. The NVIDIA GPU will stay powered off until explicitly used, significantly improving battery runtime during normal use.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.