From 1963db67145d38469cf09f2464f0cee9bb17afc0 Mon Sep 17 00:00:00 2001 From: Chris Toph Date: Mon, 31 Mar 2025 12:19:32 -0400 Subject: [PATCH] Add nix-gaming input for pulse low latency, fixup gamescope and gamemode --- flake.nix | 7 +++++ home/toph/common/optional/gaming/default.nix | 27 ++++++++++++++++---- hosts/common/optional/audio.nix | 10 ++++++-- hosts/common/optional/gaming.nix | 13 ++++++++-- hosts/users/default.nix | 3 ++- 5 files changed, 50 insertions(+), 10 deletions(-) diff --git a/flake.nix b/flake.nix index 3832262..c6b190a 100644 --- a/flake.nix +++ b/flake.nix @@ -67,6 +67,13 @@ ## Misc Packages ## + nix-gaming = { + url = "github:fufexan/nix-gaming"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; + # nixcord.url = "github:kaylorben/nixcord"; # spicetify-nix = { # url = "github:Gerg-L/spicetify-nix"; diff --git a/home/toph/common/optional/gaming/default.nix b/home/toph/common/optional/gaming/default.nix index 5dae89b..efb150d 100644 --- a/home/toph/common/optional/gaming/default.nix +++ b/home/toph/common/optional/gaming/default.nix @@ -8,32 +8,41 @@ }: let - # monitor = lib.head (lib.filter (m: m.primary) config.monitors); + monitor = lib.head (lib.filter (m: m.primary) config.monitors); steam-session = let gamescope = lib.concatStringsSep " " [ (lib.getExe pkgs.gamescope) - # "--output-width ${toString monitor.width}" - # "--output-height ${toString monitor.height}" - # "--framerate-limit ${toString monitor.refreshRate}" - # "--prefer-output ${monitor.name}" + "--rt" + "--output-width ${toString monitor.width}" + "--output-height ${toString monitor.height}" + "--framerate-limit ${toString monitor.refreshRate}" + "--prefer-output ${monitor.name}" "--adaptive-sync" "--expose-wayland" + "--backend wayland" "--steam" # "--hdr-enabled" ]; steam = lib.concatStringsSep " " [ "steam" #"steam://open/bigpicture" + "-forcedesktopscaling ${toString monitor.scale}" + "-nofriendsui" + "-noschatui" ]; in pkgs.writeTextDir "share/applications/steam-session.desktop" '' [Desktop Entry] Name=Steam Session + Comment=Steam with Gamescope Exec=${gamescope} -- ${steam} Icon=steam Type=Application + Categories=Network;FileTransfer;Game; + MimeType=x-scheme-handler/steam;x-scheme-handler/steamlink; + PrefersNonDefaultGPU = true; ''; in { @@ -41,5 +50,13 @@ in steam-session prismlauncher # modrinth-app + (lutris.override { + extraLibraries = pkgs: [ + # List library dependencies here + ]; + extraPkgs = pkgs: [ + # List package dependencies here + ]; + }) ]; } diff --git a/hosts/common/optional/audio.nix b/hosts/common/optional/audio.nix index 5c306da..5e4ab5e 100644 --- a/hosts/common/optional/audio.nix +++ b/hosts/common/optional/audio.nix @@ -1,15 +1,20 @@ -{ pkgs, ... }: +{ pkgs, inputs, ... }: { - # sound.enable = true; #deprecated in 24.11 TODO remove this line when 24.11 release + imports = [ + inputs.nix-gaming.nixosModules.pipewireLowLatency + ]; + services.pulseaudio.enable = false; security.rtkit.enable = true; services.pipewire = { enable = true; + alsa.enable = true; alsa.support32Bit = true; pulse.enable = true; wireplumber.enable = true; jack.enable = true; + lowLatency.enable = true; # use the example session manager (no others are packaged yet so this is enabled by default, # no need to redefine it in your config for now) @@ -19,6 +24,7 @@ environment.systemPackages = builtins.attrValues { inherit (pkgs) playerctl # cli utility and lib for controlling media players + pavucontrol # pamixer # cli pulseaudio sound mixer ; }; diff --git a/hosts/common/optional/gaming.nix b/hosts/common/optional/gaming.nix index 8bd8354..947e28c 100644 --- a/hosts/common/optional/gaming.nix +++ b/hosts/common/optional/gaming.nix @@ -1,4 +1,9 @@ -{ pkgs, ... }: +{ + pkgs, + lib, + config, + ... +}: { hardware.xone.enable = true; # xbox controller @@ -9,6 +14,7 @@ enable = true; package = pkgs.protontricks; }; + package = pkgs.steam.override { extraPkgs = pkgs: @@ -31,10 +37,12 @@ libkrb5 keyutils gperftools + gamemode ; }); }; extraCompatPackages = [ pkgs.unstable.proton-ge-bin ]; + gamescopeSession.enable = true; }; #gamescope launch args set dynamically in home//common/optional/gaming gamescope = { @@ -48,8 +56,9 @@ settings = { #see gamemode man page for settings info general = { - softrealtime = "on"; + softrealtime = "auto"; inhibit_screensaver = 1; + renice = 15; }; gpu = { apply_gpu_optimisations = "accept-responsibility"; diff --git a/hosts/users/default.nix b/hosts/users/default.nix index fb8d14b..377effc 100644 --- a/hosts/users/default.nix +++ b/hosts/users/default.nix @@ -32,10 +32,11 @@ in "wheel" (ifTheyExist [ "audio" - "video" "docker" + "gamemode" "git" "networkmanager" + "video" ]) ]; };