~cyplo/dotfiles

a666dbea18baf738decaec41dbb4c0525deab74e — Cyryl Płotnicki 3 months ago 3a6ea1b
nvidia driver on foureighty
2 files changed, 26 insertions(+), 0 deletions(-)

M nixos/boxes/foureighty/default.nix
A nixos/boxes/foureighty/nvidia.nix
M nixos/boxes/foureighty/default.nix => nixos/boxes/foureighty/default.nix +1 -0
@@ 5,6 5,7 @@
  imports = [
    inputs.nixos-hardware.nixosModules.lenovo-thinkpad-t480
    ./hardware-configuration.nix
    ./nvidia.nix
    ../../boot.nix
    ../../common.nix
    ../../gfx-intel.nix

A nixos/boxes/foureighty/nvidia.nix => nixos/boxes/foureighty/nvidia.nix +25 -0
@@ 0,0 1,25 @@
{ 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 -a "$0" "$@"
  '';
in
  {
    environment.systemPackages = [ nvidia-offload ];

    services.xserver.videoDrivers = [ "nvidia" ];
    hardware.nvidia.prime = {
      offload.enable = true;

    # Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA
    intelBusId = "PCI:0:2:0";

    # Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA
    nvidiaBusId = "PCI:1:0:0";
  };
}