common/gpu/nvidia*: Migrate to common/gpu/nvidia/* and add non-prime

Fixes #338
This commit is contained in:
Tristan Daniël Maat 2022-11-13 01:32:01 +00:00
parent 062c3cca46
commit 7e60458d86
No known key found for this signature in database
GPG key ID: 49670FD774E43268
6 changed files with 57 additions and 29 deletions

View file

@ -1,9 +1,11 @@
{ lib, pkgs, ... }:
{ {
# This runs only intel/amdgpu igpus and nvidia dgpus do not drain power. imports = [ ./nvidia/disable.nix ];
##### disable nvidia, very nice battery life. warnings = [
hardware.nvidiaOptimus.disable = lib.mkDefault true; ''
boot.blacklistedKernelModules = lib.mkDefault [ "nouveau" "nvidia" ]; DEPRECATED: The <nixos-hardware/common/gpu/nvidia-disable.nix> module has been deprecated.
Switch to using <nixos-hardware/common/gpu/nvidia/disable.nix> instead.
''
];
} }

View file

@ -1,26 +1,12 @@
{ lib, pkgs, ... }:
# This creates a new 'nvidia-offload' program that runs the application passed to it on the GPU
# As per https://nixos.wiki/wiki/Nvidia
let
nvidia-offload = 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 "$@"
'';
in
{ {
services.xserver.videoDrivers = lib.mkDefault [ "nvidia" ]; imports = [ ./nvidia/prime.nix ];
environment.systemPackages = [ nvidia-offload ];
hardware.nvidia.prime = { warnings = [
offload.enable = lib.mkDefault true; ''
# Hardware should specify the bus ID for intel/nvidia devices DEPRECATED: The <nixos-hardware/common/gpu/nvidia.nix> module has been deprecated.
};
hardware.opengl.extraPackages = with pkgs; [ Switch to using <nixos-hardware/common/gpu/nvidia/prime.nix> instead if you use prime offloading.
vaapiVdpau If you are using this without prime, consider switching to <nixos-hardware/common/gpu/nvidia> instead.
''
]; ];
} }

View file

@ -0,0 +1,8 @@
{ lib, pkgs, ... }:
{
services.xserver.videoDrivers = lib.mkDefault [ "nvidia" ];
hardware.opengl.extraPackages = with pkgs; [
vaapiVdpau
];
}

View file

@ -0,0 +1,9 @@
{ lib, pkgs, ... }:
{
# This runs only intel/amdgpu igpus and nvidia dgpus do not drain power.
##### disable nvidia, very nice battery life.
hardware.nvidiaOptimus.disable = lib.mkDefault true;
boot.blacklistedKernelModules = lib.mkDefault [ "nouveau" "nvidia" ];
}

View file

@ -0,0 +1,22 @@
{ lib, pkgs, ... }:
# This creates a new 'nvidia-offload' program that runs the application passed to it on the GPU
# As per https://nixos.wiki/wiki/Nvidia
let
nvidia-offload = 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 "$@"
'';
in {
imports = [ ./. ];
environment.systemPackages = [ nvidia-offload ];
hardware.nvidia.prime = {
offload.enable = lib.mkDefault true;
# Hardware should specify the bus ID for intel/nvidia devices
};
}

View file

@ -157,8 +157,9 @@
common-gpu-amd-sea-islands = import ./common/gpu/amd/sea-islands; common-gpu-amd-sea-islands = import ./common/gpu/amd/sea-islands;
common-gpu-amd-southern-islands = import ./common/gpu/amd/southern-islands; common-gpu-amd-southern-islands = import ./common/gpu/amd/southern-islands;
common-gpu-intel = import ./common/gpu/intel.nix; common-gpu-intel = import ./common/gpu/intel.nix;
common-gpu-nvidia = import ./common/gpu/nvidia.nix; common-gpu-nvidia = import ./common/gpu/nvidia/prime.nix;
common-gpu-nvidia-disable = import ./common/gpu/nvidia-disable.nix; common-gpu-nvidia-nonprime = import ./common/gpu/nvidia;
common-gpu-nvidia-disable = import ./common/gpu/nvidia/disable.nix;
common-pc = import ./common/pc; common-pc = import ./common/pc;
common-pc-hdd = import ./common/pc/hdd; common-pc-hdd = import ./common/pc/hdd;
common-pc-laptop = import ./common/pc/laptop; common-pc-laptop = import ./common/pc/laptop;