From d2baeeba6df4c58c806bf1f34e6dec98c35a36af Mon Sep 17 00:00:00 2001 From: kenji Date: Mon, 30 Jun 2025 14:20:06 -0500 Subject: [PATCH] added gaming scopes --- home/desktop.nix | 18 ++++++++---- modules/gaming.nix | 72 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 modules/gaming.nix diff --git a/home/desktop.nix b/home/desktop.nix index 8daf6d7..d2b9dea 100644 --- a/home/desktop.nix +++ b/home/desktop.nix @@ -1,8 +1,16 @@ -{myConfig, ...}: { - imports = [ - ../modules/terminal.nix - ../modules/desktop.nix - ]; +{ + myConfig, + lib, + ... +}: { + imports = + [ + ../modules/terminal.nix + ../modules/desktop.nix + ] + ++ lib.optionals (myConfig.linux.gaming == true) [ + ../modules/gaming.nix + ]; programs.home-manager.enable = true; diff --git a/modules/gaming.nix b/modules/gaming.nix new file mode 100644 index 0000000..b27f5f4 --- /dev/null +++ b/modules/gaming.nix @@ -0,0 +1,72 @@ +# In your ~/.config/home-manager/home.nix (or a file imported by it) +{ + config, + pkgs, + ... +}: +# Home Manager modules usually get config and pkgs as arguments +let + # Define the custom Steam launcher script within Home Manager's scope. + # pkgs here refers to the pkgs available to your Home Manager environment. + steamGamescopeWrapper = pkgs.writeScriptBin "steam-gamescope-launcher" '' + #!/usr/bin/env bash + set -xeuo pipefail + + gamescopeArgs=( + --adaptive-sync + --hdr-enabled + --mangoapp + --rt + --steam + ) + steamArgs=( + -pipewire-dmabuf + -tenfoot + ) + mangoConfig=( + cpu_temp + gpu_temp + ram + vram + ) + mangoVars=( + MANGOHUD=1 + MANGOHUD_CONFIG="$(IFS=,; echo "$${mangoConfig[*]}")" + ) + + export PATH="${pkgs.gamescope}/bin:${pkgs.mangohud}/bin:$PATH" + + export "$${mangoVars[@]}" + exec ${pkgs.gamescope}/bin/gamescope "$${gamescopeArgs[@]}" -- ${pkgs.steam}/bin/steam "$${steamArgs[@]}" + ''; +in { + # You don't need 'programs.xdg.enable = true;' explicitly here in Home Manager; + # xdg.desktopEntries will be available directly once Home Manager is active. + + # Home Manager usually manages user-level packages under `home.packages`. + home.packages = with pkgs; [ + protonup-qt + mangohud + goverlay + steamGamescopeWrapper # Add your wrapper script to your user's PATH + ]; + + # Define the desktop entry within Home Manager's xdg.desktopEntries + xdg.desktopEntries.steam = { + name = "Steam (Gamescope)"; + comment = "Launch Steam via Gamescope with MangoHud"; + exec = "${steamGamescopeWrapper}"; + icon = "steam"; + terminal = false; + type = "Application"; + categories = ["Game" "Application"]; + startupNotify = true; + }; + + # If you previously had services.getty.autologinUser, that remains in configuration.nix. + # Likewise for hardware.xone.enable and boot.kernelPackages. + + # Note: programs.steam.enable, programs.gamescope.enable, hardware.xone.enable + # usually remain in configuration.nix (system-wide), as they install the programs + # and drivers for the whole system. +}