blob: f7aa1bda8ec4553ea6a4e8e00cf73634d2b75b6e [file] [log] [blame]
Skyler Greyf2335ec2022-11-02 08:10:50 +00001{ pkgs, ... }:
2let
3 prime-run = pkgs.writeScriptBin "prime-run" ''
4 export __NV_PRIME_RENDER_OFFLOAD=1
5 export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
6 export __GLX_VENDOR_LIBRARY_NAME=nvidia
7 export __VK_LAYER_NV_optimus=NVIDIA_only
8 exec "$@"
9 '';
10in
11{
12 config = {
Skyler Greya1683e32022-11-03 08:05:34 +000013 services.xserver.videoDrivers = [ "nvidia" ];
Skyler Greyf2335ec2022-11-02 08:10:50 +000014 hardware = {
15 opengl.enable = true;
16 nvidia = {
17 modesetting.enable = true;
18 prime = {
19 offload.enable = true;
20 intelBusId = "PCI:0:2:0";
21 nvidiaBusId = "PCI:1:0:0";
22 };
23 };
24 };
25 internal.allowUnfree = [ "nvidia-x11" "nvidia-settings" "cudatoolkit" ];
26 };
27 home.home.packages = [ pkgs.nvtop prime-run ];
28}