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.

72 lines
1.8 KiB

  1. { lib, 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. # Blacklist the open source driver.
  14. boot.blacklistedKernelModules = [ "nouveau" ];
  15. # Add the offload script to the $PATH.
  16. environment.systemPackages = [ myNvidiaOffload ];
  17. # Configure XDG compliance.
  18. environment.variables = {
  19. __GL_SHADER_DISK_CACHE_PATH = "$XDG_CACHE_HOME/nv";
  20. CUDA_CACHE_PATH = "$XDG_CACHE_HOME/nv";
  21. };
  22. # Enable the NVIDIA drivers.
  23. services.xserver.videoDrivers = [ "nvidia" ];
  24. # Fix screen tearing.
  25. services.xserver.screenSection = ''
  26. Option "metamodes" "nvidia-auto-select +0+0 {ForceFullCompositionPipeline=On}"
  27. Option "AllowIndirectGLXProtocol" "off"
  28. Option "TripleBuffer" "on"
  29. '';
  30. # Fix graphical corruption on suspend.
  31. hardware.nvidia.powerManagement.enable = true;
  32. # Configure `offload-mode'.
  33. hardware.nvidia.prime = {
  34. offload.enable = true;
  35. intelBusId = myIntelBusId;
  36. nvidiaBusId = myNvidiaBusId;
  37. };
  38. # Add OpenGL support.
  39. hardware.opengl = {
  40. enable = true;
  41. driSupport = true;
  42. driSupport32Bit = true;
  43. extraPackages32 = with pkgs; [
  44. pkgsi686Linux.libva
  45. intel-media-driver
  46. vaapiIntel
  47. ];
  48. };
  49. # Create an external display setup.
  50. specialisation = {
  51. external-display.configuration = {
  52. system.nixos.tags = [ "external-display" ];
  53. hardware.nvidia.prime.offload.enable = lib.mkForce false;
  54. hardware.nvidia.powerManagement.enable = lib.mkForce false;
  55. };
  56. };
  57. # Add user to video group.
  58. users.users.chris = {
  59. extraGroups = [ "video" ];
  60. };
  61. }