2022-11-12 20:32:01 -05:00
|
|
|
{ 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 = {
|
2023-02-08 23:41:39 -05:00
|
|
|
offload.enable = lib.mkOverride 990 true;
|
2022-11-12 20:32:01 -05:00
|
|
|
# Hardware should specify the bus ID for intel/nvidia devices
|
|
|
|
};
|
|
|
|
}
|