~ruther/nixos-config

ref: 83a8a9540adf86155220703b70c5fbdc9c6c3def nixos-config/modules/hardware/work/nvidia.nix -rw-r--r-- 1.0 KiB
83a8a954 — Frantisek Bohacek feat: some updates 1 year, 3 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#
# NVIDIA drivers so that the laptop video card can get offloaded to specific applications.
# Either start the desktop or packages using nvidia-offload.
# For example $ nvidia-offload kdenlive
# Currently only used with work laptop using NVIDIA MX330
#

{ 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
{
  environment.systemPackages = [ nvidia-offload ];

  services.xserver.videoDrivers = [ "nvidia" ];
  hardware = {
    opengl.enable = true;
    nvidia = {
      package = config.boot.kernelPackages.nvidiaPackages.stable;
      prime = {
        offload.enable = true;
        intelBusId = "PCI:0:2:0";
        nvidiaBusId = "PCI:45:0:0";
      };
      modesetting.enable = true;
      powerManagement.enable = true;
    };
  };

  #boot.kernelParams = [ "modules_blacklist=i915" ];
}
Do not follow this link