mirror of
https://github.com/NixOS/nixos-hardware
synced 2024-12-04 08:49:43 +01:00
Moved NVIDIA config to common, and updated README.
This commit is contained in:
parent
6ffcdbacc5
commit
b7a5f1188f
4 changed files with 34 additions and 20 deletions
22
common/gpu/nvidia.nix
Normal file
22
common/gpu/nvidia.nix
Normal 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 -a "$0" "$@"
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
services.xserver.videoDrivers = lib.mkDefault [ "nvidia" ];
|
||||||
|
environment.systemPackages = [ nvidia-offload ];
|
||||||
|
|
||||||
|
hardware.nvidia.prime = {
|
||||||
|
offload.enable = lib.mkDefault true;
|
||||||
|
# Hardware should specify the bus ID for intel/nvidia devices
|
||||||
|
};
|
||||||
|
}
|
|
@ -12,3 +12,11 @@
|
||||||
== Notes ==
|
== Notes ==
|
||||||
|
|
||||||
Also tested with Dell WD19TB Thunderbolt Dock.
|
Also tested with Dell WD19TB Thunderbolt Dock.
|
||||||
|
|
||||||
|
== NVIDIA Offload ==
|
||||||
|
|
||||||
|
In order to run a program on the NVIDIA gpu, you can use the `nvidia-offload` function, for example:
|
||||||
|
```
|
||||||
|
nvidia-offload `nix-shell -p glxinfo --run 'glxgears'`
|
||||||
|
```
|
||||||
|
This is a short bash script that sets the proper environment variables and calls your command.
|
||||||
|
|
|
@ -1,27 +1,11 @@
|
||||||
{ lib, pkgs, ... }:
|
{ lib, pkgs, ... }:
|
||||||
|
|
||||||
# This creates a new 'nvidia-offload' program that runs the application passed to it on the GPU
|
|
||||||
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 -a "$0" "$@"
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../xps-common.nix
|
../xps-common.nix
|
||||||
|
../../../../common/gpu/nvidia.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# As per https://nixos.wiki/wiki/Nvidia
|
|
||||||
services.xserver.videoDrivers = lib.mkDefault [ "nvidia" ];
|
|
||||||
environment.systemPackages = [ nvidia-offload ];
|
|
||||||
|
|
||||||
hardware.nvidia.prime = {
|
hardware.nvidia.prime = {
|
||||||
offload.enable = lib.mkDefault true;
|
|
||||||
|
|
||||||
# Bus ID of the Intel GPU.
|
# Bus ID of the Intel GPU.
|
||||||
intelBusId = lib.mkDefault "PCI:0:2:0";
|
intelBusId = lib.mkDefault "PCI:0:2:0";
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,10 @@ in
|
||||||
# This will save you money and possibly your life!
|
# This will save you money and possibly your life!
|
||||||
services.thermald.enable = lib.mkDefault true;
|
services.thermald.enable = lib.mkDefault true;
|
||||||
|
|
||||||
# Thermald doesn't have a default config for the 9500 yet, the one in this repo was generated with dptfxtract-static:
|
# Thermald doesn't have a default config for the 9500 yet, the one in this repo
|
||||||
|
# was generated with dptfxtract-static (https://github.com/intel/dptfxtract)
|
||||||
services.thermald.configFile = lib.mkDefault thermald-conf;
|
services.thermald.configFile = lib.mkDefault thermald-conf;
|
||||||
|
|
||||||
# Set the tlp config to powersave explictly (this should be default). TLP is enabled in common/pc/laptop.
|
# Set the tlp config to powersave explictly. TLP is enabled in common/pc/laptop.
|
||||||
services.tlp.extraConfig = lib.mkDefault "CPU_SCALING_GOVERNOR_ON_AC=powersave\nCPU_SCALING_GOVERNOR_ON_BAT=powersave";
|
services.tlp.extraConfig = lib.mkDefault "CPU_SCALING_GOVERNOR_ON_AC=powersave\nCPU_SCALING_GOVERNOR_ON_BAT=powersave";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue