sisyphus/nixos/modules/hardware/nvidia.nix
2023-11-19 15:37:51 +01:00

33 lines
794 B
Nix

{ inputs, lib, config, pkgs, ... }:
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
{
nixpkgs.config.allowUnfree = true;
services.xserver.videoDrivers = [ "nvidia" ];
hardware = {
opengl.enable = true;
nvidia = {
open = true;
package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true;
};
};
# Offloading
# environment.systemPackages = [ nvidia-offload ];
# hardware.nvidia.prime = {
# offload.enable = true;
# intelBusId = "PCI::00:02:0";
# nvidiaBusId = "PCI:01:00:0";
# };
}