Skyler Grey | 6ec7b41 | 2023-01-26 00:38:49 +0000 | [diff] [blame] | 1 | { pkgs, lib, username, ... }: |
Skyler Grey | f2335ec | 2022-11-02 08:10:50 +0000 | [diff] [blame] | 2 | let |
| 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 | ''; |
| 10 | in |
| 11 | { |
| 12 | config = { |
Skyler Grey | a1683e3 | 2022-11-03 08:05:34 +0000 | [diff] [blame] | 13 | services.xserver.videoDrivers = [ "nvidia" ]; |
Skyler Grey | f2335ec | 2022-11-02 08:10:50 +0000 | [diff] [blame] | 14 | hardware = { |
| 15 | opengl.enable = true; |
| 16 | nvidia = { |
| 17 | modesetting.enable = true; |
Skyler Grey | 6ec7b41 | 2023-01-26 00:38:49 +0000 | [diff] [blame] | 18 | powerManagement.enable = true; |
Skyler Grey | f2335ec | 2022-11-02 08:10:50 +0000 | [diff] [blame] | 19 | prime = { |
| 20 | offload.enable = true; |
| 21 | intelBusId = "PCI:0:2:0"; |
| 22 | nvidiaBusId = "PCI:1:0:0"; |
| 23 | }; |
| 24 | }; |
| 25 | }; |
Skyler Grey | 6ec7b41 | 2023-01-26 00:38:49 +0000 | [diff] [blame] | 26 | |
| 27 | specialisation.nvidia-sync.configuration = { |
| 28 | system.nixos.tags = [ "nvidia-sync" ]; |
| 29 | hardware.nvidia.powerManagement.enable = lib.mkForce false; |
| 30 | hardware.nvidia.prime.offload.enable = lib.mkForce false; |
| 31 | hardware.nvidia.prime.sync.enable = lib.mkForce true; |
| 32 | services.xserver.dpi = 96; |
| 33 | |
| 34 | home-manager.users.${username}.home.file.".xinitrc".text = lib.mkBefore '' |
| 35 | ${pkgs.xorg.xrandr}/bin/xrandr --setprovideroutputsource modesetting NVIDIA-0 |
| 36 | ${pkgs.xorg.xrandr}/bin/xrandr --output HDMI-0 --primary --mode 3840x2160 --pos 0x0 --rotate normal --output eDP-1-1 --mode 1920x1080 --pos 960x2160 --rotate normal |
| 37 | ''; |
| 38 | }; |
| 39 | |
Skyler Grey | f2335ec | 2022-11-02 08:10:50 +0000 | [diff] [blame] | 40 | internal.allowUnfree = [ "nvidia-x11" "nvidia-settings" "cudatoolkit" ]; |
| 41 | }; |
| 42 | home.home.packages = [ pkgs.nvtop prime-run ]; |
| 43 | } |