From 8332e27e1d44195377ee3fc1d6da4704f01a17ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Sun, 27 Jun 2021 12:13:57 +0100 Subject: [PATCH] nvidia driver on foureighty --- nixos/boxes/foureighty/default.nix | 1 + nixos/boxes/foureighty/nvidia.nix | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 nixos/boxes/foureighty/nvidia.nix diff --git a/nixos/boxes/foureighty/default.nix b/nixos/boxes/foureighty/default.nix index 379c8886..cbcc9007 100644 --- a/nixos/boxes/foureighty/default.nix +++ b/nixos/boxes/foureighty/default.nix @@ -5,6 +5,7 @@ imports = [ inputs.nixos-hardware.nixosModules.lenovo-thinkpad-t480 ./hardware-configuration.nix + ./nvidia.nix ../../boot.nix ../../common.nix ../../gfx-intel.nix diff --git a/nixos/boxes/foureighty/nvidia.nix b/nixos/boxes/foureighty/nvidia.nix new file mode 100644 index 00000000..09cefd97 --- /dev/null +++ b/nixos/boxes/foureighty/nvidia.nix @@ -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"; + }; +}