mirror of
				https://github.com/NixOS/nixos-hardware.git
				synced 2025-11-04 17:27:14 +08:00 
			
		
		
		
	Moved NVIDIA config to common, and updated README.
This commit is contained in:
		@@ -12,3 +12,11 @@
 | 
			
		||||
== Notes ==
 | 
			
		||||
 | 
			
		||||
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, ... }:
 | 
			
		||||
 | 
			
		||||
# 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 = [
 | 
			
		||||
    ../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 = {
 | 
			
		||||
    offload.enable = lib.mkDefault true;
 | 
			
		||||
 | 
			
		||||
    # Bus ID of the Intel GPU.
 | 
			
		||||
    intelBusId = lib.mkDefault "PCI:0:2:0";
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -15,10 +15,10 @@ in
 | 
			
		||||
  # This will save you money and possibly your life!
 | 
			
		||||
  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;
 | 
			
		||||
 | 
			
		||||
  # 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";
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user