From 01781658b87f573f05e1fa3f48be810656b93d84 Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 9 Feb 2023 10:44:49 +0530 Subject: working config --- home.nix | 2 ++ hosts/myrtle/configuration.nix | 47 +++++++++++++++++++++++++----------------- scripts/default.nix | 3 +++ scripts/nvidia-offload.nix | 12 +++++++++++ 4 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 scripts/nvidia-offload.nix diff --git a/home.nix b/home.nix index 8f89697..b801b7f 100644 --- a/home.nix +++ b/home.nix @@ -115,6 +115,8 @@ initExtra = '' ${pkgs.hsetroot}/bin/hsetroot -solid "${theme.base00}" xrdb -load $HOME/.Xresources + xrandr --setprovideroutputsource modesetting NVIDIA-0 + xrandr --auto ''; }; diff --git a/hosts/myrtle/configuration.nix b/hosts/myrtle/configuration.nix index 74f4861..f0bcb81 100644 --- a/hosts/myrtle/configuration.nix +++ b/hosts/myrtle/configuration.nix @@ -12,8 +12,8 @@ boot.kernelPackages = pkgs.linuxPackages_latest; boot.blacklistedKernelModules = [ "nouveau" ]; boot.kernelParams = [ - "i915.modeset=0" - # "intel_pstate=disable" + # "i915.modeset=0" + # "intel_pstate=disable" ]; networking = { @@ -106,14 +106,14 @@ nvidia = { prime = { offload.enable = true; - intelBusId = "PCI:00:02:0"; - nvidiaBusId = "PCI:01:00:0"; + intelBusId = "PCI:0:2:0"; + nvidiaBusId = "PCI:1:0:0"; }; package = config.boot.kernelPackages.nvidiaPackages.latest; - powerManagement = { - enable = true; - finegrained = true; - }; + # powerManagement = { + # enable = true; + # finegrained = true; + # }; }; }; @@ -126,22 +126,31 @@ xserver = { enable = true; layout = "us"; - videoDrivers = [ "nvidia" "intel" ]; + videoDrivers = [ "nvidia" ]; displayManager.startx.enable = true; - dpi = 192; libinput.enable = true; - serverLayoutSection = '' - Screen "Screen-nvidia[0]" - ''; - config = lib.mkAfter '' - Section "Screen" - Identifier "Screen-nvidia[0]" - Device "Device-nvidia[0]" - EndSection + dpi = 192; + screenSection = '' + Option "metamodes" "nvidia-auto-select +0+0 {ForceFullCompositionPipeline=On}" + Option "AllowIndirectGLXProtocol" "off" + Option "TripleBuffer" "on" ''; + # serverLayoutSection = lib.mkAfter '' + # Screen 0 "Screen-nvidia[0]" + # ''; + # config = lib.mkAfter '' + # Section "Screen" + # Identifier "Screen-nvidia[0]" + # Device "Device-nvidia[0]" + # EndSection + # ''; }; - openssh.enable = true; + openssh = { + enable = true; + forwardX11 = true; + allowSFTP = true; + }; asusd = { enable = true; diff --git a/scripts/default.nix b/scripts/default.nix index 220d76d..f134556 100644 --- a/scripts/default.nix +++ b/scripts/default.nix @@ -36,6 +36,9 @@ let # battery script battery = import ./battery.nix pkgs; + # run-on-gpu script + battery = import ./nvidia-offload.nix pkgs; + # fzf script to switch between tmux sessions tmux-fzf = pkgs.writeScriptBin "tmux-fzf" '' LIST_DATA="#{session_name}/#{window_name}/#{pane_current_command} @ #{pane_current_path}" diff --git a/scripts/nvidia-offload.nix b/scripts/nvidia-offload.nix new file mode 100644 index 0000000..de55fa2 --- /dev/null +++ b/scripts/nvidia-offload.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: + +let + name = "nvidia-offload"; +in +pkgs.writeShellScriptBin name '' + 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 "$@" +'' -- cgit v1.2.3