From 3bd899bc13bbba4a68de61e5dcea5a4bbcc3bc12 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Mon, 6 Feb 2023 09:21:35 +0000 Subject: [PATCH] NVidia setup --- system/configuration.nix | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/system/configuration.nix b/system/configuration.nix index eb6cbde..764e5cf 100644 --- a/system/configuration.nix +++ b/system/configuration.nix @@ -1,5 +1,14 @@ { 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 { imports = [ @@ -11,7 +20,7 @@ boot.loader.efi.canTouchEfiVariables = true; networking.hostName = "thompson"; - networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + networking.networkmanager.enable = true; time.timeZone = "Europe/London"; @@ -36,12 +45,26 @@ services.xserver.enable = true; services.xserver.displayManager.sddm.enable = true; services.xserver.desktopManager.plasma5.enable = true; + hardware.nvidia.modesetting.enable = true; + services.xserver.videoDrivers = ["nvidia" ]; + + hardware.opengl.enable = true; + hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable; + hardware.nvidia.prime = { + sync.enable = true; + nvidiaBusId = "PCI:1:0:0"; + intelBusId = "PCI:0:2:0"; + }; + + hardware.bluetooth.enable = true; environment.systemPackages = with pkgs; [ neovim wget tmux git + pciutils + nvidia-offload ]; nixpkgs.config.allowUnfree = true;