diff --git a/nixos/profiles/opt-in/gaming.nix b/nixos/profiles/opt-in/gaming.nix index 9c26fda..5e16ae1 100644 --- a/nixos/profiles/opt-in/gaming.nix +++ b/nixos/profiles/opt-in/gaming.nix @@ -1,6 +1,7 @@ { pkgs, lib, + config, ... }: { myFlake.hardware.accessories.xboxOneController.enable = lib.mkDefault true; @@ -13,6 +14,18 @@ }; }; + # Integrate with NVIDIA Optimus offloading. + # https://github.com/FeralInteractive/gamemode#note-for-hybrid-gpu-users + # https://github.com/NixOS/nixpkgs/pull/273177 + environment.sessionVariables = { + "GAMEMODERUNEXEC" = let + inherit (config.hardware.nvidia.prime) offload; + in + lib.mkIf + (builtins.elem "nvidia" config.services.xserver.videoDrivers || offload.enable || offload.enableOffloadCmd) + (lib.mkDefault "nvidia-offload"); + }; + ### https://wiki.archlinux.org/title/Gaming#Improving_performance systemd.tmpfiles.rules = [ # Path Mode UID GID Age Argument