laptop: graphics-related cleanup

This commit is contained in:
Lgmrszd 2025-10-16 12:26:50 +04:00
parent 626333898b
commit 6d597df30d
No known key found for this signature in database
GPG key ID: 9396B8BA6FBB14DE
3 changed files with 33 additions and 13 deletions

View file

@ -89,7 +89,7 @@
}; };
my-overlays = [ my-overlays = [
overlay-stable overlay-stable
overlay-vaapiIntel # overlay-vaapiIntel
overlay-nitrokey-udev-update overlay-nitrokey-udev-update
]; ];
inherit (inputs.nix-cfg-extra.lib) extra-data; inherit (inputs.nix-cfg-extra.lib) extra-data;

View file

@ -111,12 +111,12 @@ in
hardware.graphics = { hardware.graphics = {
enable = true; enable = true;
# These extrapackages I added later but it didn't help # These extrapackages I added later but it didn't help
extraPackages = with pkgs; [ # extraPackages = with pkgs; [
intel-media-driver # LIBVA_DRIVER_NAME=iHD # intel-media-driver # LIBVA_DRIVER_NAME=iHD
vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium) # vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
vaapiVdpau # vaapiVdpau
libvdpau-va-gl # libvdpau-va-gl
]; # ];
}; };
# Tell Xorg to use the nvidia driver (also valid for Wayland) # Tell Xorg to use the nvidia driver (also valid for Wayland)
services.xserver.videoDrivers = ["nvidia"]; services.xserver.videoDrivers = ["nvidia"];
@ -126,7 +126,7 @@ in
modesetting.enable = true; modesetting.enable = true;
# Use the open source version of the kernel module # Use the open source version of the kernel module
# Only available on driver 515.43.04+ # Only available on driver 515.43.04+
open = false; open = true;
# Enable the nvidia settings menu # Enable the nvidia settings menu
nvidiaSettings = true; nvidiaSettings = true;
powerManagement.enable = true; powerManagement.enable = true;
@ -136,7 +136,7 @@ in
}; };
# NVIDIA # NVIDIA
hardware.nvidia.prime = { hardware.nvidia.prime = lib.mkIf (config.specialisation != {}) {
offload = { offload = {
enable = true; enable = true;
enableOffloadCmd = true; enableOffloadCmd = true;
@ -147,13 +147,33 @@ in
nvidiaBusId = "PCI:1:0:0"; nvidiaBusId = "PCI:1:0:0";
}; };
specialisation."dGPU-only".configuration = {
environment.etc."specialisation".text = "dGPU-only";
system.nixos.tags = ["dGPU-only"];
# hardware.nvidia.prime = {
# offload.enable = lib.mkForce false;
# offload.enableOffloadCmd = lib.mkForce false;
# sync.enable = lib.mkForce true;
# };
environment.systemPackages = [
(pkgs.writeShellScriptBin "nvidia-offload" ''
echo "nvidia full mode on, simply executing $@"
exec "$@"
'')
];
# boot.kernelParams = [ "module_blacklist=i915" ];
};
specialisation."nvidia-full".configuration = { specialisation."nvidia-full".configuration = {
environment.etc."specialisation".text = "nvidia-full"; environment.etc."specialisation".text = "nvidia-full";
system.nixos.tags = ["nvidia-full"]; system.nixos.tags = ["nvidia-full"];
hardware.nvidia.prime = { hardware.nvidia.prime = {
offload.enable = lib.mkForce false; offload.enable = false;
offload.enableOffloadCmd = lib.mkForce false; offload.enableOffloadCmd = false;
sync.enable = lib.mkForce true; sync.enable = true;
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
}; };
environment.systemPackages = [ environment.systemPackages = [
(pkgs.writeShellScriptBin "nvidia-offload" '' (pkgs.writeShellScriptBin "nvidia-offload" ''

View file

@ -16,7 +16,7 @@ in
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "ahci" "nvme" "usbhid" "uas" "usb_storage" "rtsx_pci_sdmmc" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "ahci" "nvme" "usbhid" "uas" "usb_storage" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ "dm-snapshot" ]; boot.initrd.kernelModules = [ "dm-snapshot" ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.kernelParams = [ "i915.enable_psr=0" "nvidia.NVreg_PreserveVideoMemoryAllocations=1" ]; boot.kernelParams = [ "i915.enable_psr=0" ];
boot.extraModulePackages = with config.boot.kernelPackages; [ acpi_call ]; boot.extraModulePackages = with config.boot.kernelPackages; [ acpi_call ];
fileSystems."/" = fileSystems."/" =