I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

  1. { config, pkgs, ... }:
  2. let
  3. myIntelBusId = "PCI:0:2:0";
  4. myNvidiaBusId = "PCI:1:0:0";
  5. myNvidiaOffload = pkgs.writeShellScriptBin "nvidia-offload" ''
  6. export __NV_PRIME_RENDER_OFFLOAD=1
  7. export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
  8. export __GLX_VENDOR_LIBRARY_NAME=nvidia
  9. export __VK_LAYER_NV_optimus=NVIDIA_only
  10. exec -a "$0" "$@"
  11. '';
  12. in {
  13. # Add the offload script to the $PATH.
  14. environment.systemPackages = [ myNvidiaOffload ];
  15. # Configure XDG compliance.
  16. environment.variables = {
  17. __GL_SHADER_DISK_CACHE_PATH = "$XDG_CACHE_HOME/nv";
  18. CUDA_CACHE_PATH = "$XDG_CACHE_HOME/nv";
  19. };
  20. # Enable the NVIDIA drivers.
  21. services.xserver.videoDrivers = [ "nvidia" ];
  22. # Fix screen tearing.
  23. services.xserver.screenSection = ''
  24. Option "metamodes" "nvidia-auto-select +0+0 {ForceFullCompositionPipeline=On}"
  25. Option "AllowIndirectGLXProtocol" "off"
  26. Option "TripleBuffer" "on"
  27. '';
  28. # Configure `offload-mode'.
  29. hardware.nvidia.prime = {
  30. offload.enable = true;
  31. intelBusId = myIntelBusId;
  32. nvidiaBusId = myNvidiaBusId;
  33. };
  34. # Add OpenGL support.
  35. hardware.opengl = {
  36. enable = true;
  37. driSupport = true;
  38. driSupport32Bit = true;
  39. extraPackages32 = with pkgs; [
  40. pkgsi686Linux.libva
  41. intel-media-driver
  42. vaapiIntel
  43. ];
  44. };
  45. # Add user to video group.
  46. users.users.chris = {
  47. extraGroups = [ "video" ];
  48. };
  49. }