Add nix-gaming input for pulse low latency, fixup gamescope and gamemode

This commit is contained in:
Chris Toph 2025-03-31 12:19:32 -04:00
parent 6bfb44bf85
commit 1963db6714
5 changed files with 50 additions and 10 deletions

View file

@ -67,6 +67,13 @@
## Misc Packages ## ## Misc Packages ##
nix-gaming = {
url = "github:fufexan/nix-gaming";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
# nixcord.url = "github:kaylorben/nixcord"; # nixcord.url = "github:kaylorben/nixcord";
# spicetify-nix = { # spicetify-nix = {
# url = "github:Gerg-L/spicetify-nix"; # url = "github:Gerg-L/spicetify-nix";

View file

@ -8,32 +8,41 @@
}: }:
let let
# monitor = lib.head (lib.filter (m: m.primary) config.monitors); monitor = lib.head (lib.filter (m: m.primary) config.monitors);
steam-session = steam-session =
let let
gamescope = lib.concatStringsSep " " [ gamescope = lib.concatStringsSep " " [
(lib.getExe pkgs.gamescope) (lib.getExe pkgs.gamescope)
# "--output-width ${toString monitor.width}" "--rt"
# "--output-height ${toString monitor.height}" "--output-width ${toString monitor.width}"
# "--framerate-limit ${toString monitor.refreshRate}" "--output-height ${toString monitor.height}"
# "--prefer-output ${monitor.name}" "--framerate-limit ${toString monitor.refreshRate}"
"--prefer-output ${monitor.name}"
"--adaptive-sync" "--adaptive-sync"
"--expose-wayland" "--expose-wayland"
"--backend wayland"
"--steam" "--steam"
# "--hdr-enabled" # "--hdr-enabled"
]; ];
steam = lib.concatStringsSep " " [ steam = lib.concatStringsSep " " [
"steam" "steam"
#"steam://open/bigpicture" #"steam://open/bigpicture"
"-forcedesktopscaling ${toString monitor.scale}"
"-nofriendsui"
"-noschatui"
]; ];
in in
pkgs.writeTextDir "share/applications/steam-session.desktop" '' pkgs.writeTextDir "share/applications/steam-session.desktop" ''
[Desktop Entry] [Desktop Entry]
Name=Steam Session Name=Steam Session
Comment=Steam with Gamescope
Exec=${gamescope} -- ${steam} Exec=${gamescope} -- ${steam}
Icon=steam Icon=steam
Type=Application Type=Application
Categories=Network;FileTransfer;Game;
MimeType=x-scheme-handler/steam;x-scheme-handler/steamlink;
PrefersNonDefaultGPU = true;
''; '';
in in
{ {
@ -41,5 +50,13 @@ in
steam-session steam-session
prismlauncher prismlauncher
# modrinth-app # modrinth-app
(lutris.override {
extraLibraries = pkgs: [
# List library dependencies here
];
extraPkgs = pkgs: [
# List package dependencies here
];
})
]; ];
} }

View file

@ -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; services.pulseaudio.enable = false;
security.rtkit.enable = true; security.rtkit.enable = true;
services.pipewire = { services.pipewire = {
enable = true; enable = true;
alsa.enable = true; alsa.enable = true;
alsa.support32Bit = true; alsa.support32Bit = true;
pulse.enable = true; pulse.enable = true;
wireplumber.enable = true; wireplumber.enable = true;
jack.enable = true; jack.enable = true;
lowLatency.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default, # 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) # no need to redefine it in your config for now)
@ -19,6 +24,7 @@
environment.systemPackages = builtins.attrValues { environment.systemPackages = builtins.attrValues {
inherit (pkgs) inherit (pkgs)
playerctl # cli utility and lib for controlling media players playerctl # cli utility and lib for controlling media players
pavucontrol
# pamixer # cli pulseaudio sound mixer # pamixer # cli pulseaudio sound mixer
; ;
}; };

View file

@ -1,4 +1,9 @@
{ pkgs, ... }: {
pkgs,
lib,
config,
...
}:
{ {
hardware.xone.enable = true; # xbox controller hardware.xone.enable = true; # xbox controller
@ -9,6 +14,7 @@
enable = true; enable = true;
package = pkgs.protontricks; package = pkgs.protontricks;
}; };
package = pkgs.steam.override { package = pkgs.steam.override {
extraPkgs = extraPkgs =
pkgs: pkgs:
@ -31,10 +37,12 @@
libkrb5 libkrb5
keyutils keyutils
gperftools gperftools
gamemode
; ;
}); });
}; };
extraCompatPackages = [ pkgs.unstable.proton-ge-bin ]; extraCompatPackages = [ pkgs.unstable.proton-ge-bin ];
gamescopeSession.enable = true;
}; };
#gamescope launch args set dynamically in home/<user>/common/optional/gaming #gamescope launch args set dynamically in home/<user>/common/optional/gaming
gamescope = { gamescope = {
@ -48,8 +56,9 @@
settings = { settings = {
#see gamemode man page for settings info #see gamemode man page for settings info
general = { general = {
softrealtime = "on"; softrealtime = "auto";
inhibit_screensaver = 1; inhibit_screensaver = 1;
renice = 15;
}; };
gpu = { gpu = {
apply_gpu_optimisations = "accept-responsibility"; apply_gpu_optimisations = "accept-responsibility";

View file

@ -32,10 +32,11 @@ in
"wheel" "wheel"
(ifTheyExist [ (ifTheyExist [
"audio" "audio"
"video"
"docker" "docker"
"gamemode"
"git" "git"
"networkmanager" "networkmanager"
"video"
]) ])
]; ];
}; };