Optimize wrapper commands; Directly call proton-cachyos pkg

- Prioritize explicit command over package executable in wrappers
- Import and include proton-cachyos in default Steam compatibility packages
This commit is contained in:
Chris Toph 2025-06-30 10:45:19 -04:00
parent 5df8547c98
commit 38dad223cf
2 changed files with 30 additions and 7 deletions

View file

@ -18,8 +18,9 @@ let
mkWrapper = mkWrapper =
name: wrapperCfg: name: wrapperCfg:
let let
# Get the original package # Determine the command to execute
originalPackage = wrapperCfg.package; baseCommand =
if wrapperCfg.command != null then wrapperCfg.command else lib.getExe wrapperCfg.package;
# Create environment variable exports # Create environment variable exports
envExports = lib.concatStringsSep "\n" ( envExports = lib.concatStringsSep "\n" (
@ -39,7 +40,7 @@ let
${envExports} ${envExports}
# Execute with gamescoperun # Execute with gamescoperun
exec ${lib.getExe config.play.gamescoperun.package} ${extraArgs} ${lib.getExe originalPackage} $argv exec ${lib.getExe config.play.gamescoperun.package} ${extraArgs} ${baseCommand} $argv
''; '';
in in
@ -55,8 +56,20 @@ in
enable = lib.mkEnableOption "wrapper for this application"; enable = lib.mkEnableOption "wrapper for this application";
package = lib.mkOption { package = lib.mkOption {
type = lib.types.package; type = lib.types.nullOr lib.types.package;
description = "The package to wrap"; default = null;
description = "The package to wrap (used with lib.getExe if command is not specified)";
};
command = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
example = "\${lib.getExe osConfig.programs.steam.package} -tenfoot -bigpicture";
description = ''
The exact command to execute after gamescoperun and its options.
If specified, this takes precedence over the package option.
Can include arguments and flags.
'';
}; };
extraOptions = lib.mkOption { extraOptions = lib.mkOption {
@ -117,5 +130,10 @@ in
# Ensure gamescoperun is enabled if any wrappers are enabled # Ensure gamescoperun is enabled if any wrappers are enabled
play.gamescoperun.enable = lib.mkIf (lib.length (lib.attrNames cfg) > 0) true; play.gamescoperun.enable = lib.mkIf (lib.length (lib.attrNames cfg) > 0) true;
assertions = lib.mapAttrsToList (name: wrapperCfg: {
assertion = wrapperCfg.enable -> (wrapperCfg.command != null || wrapperCfg.package != null);
message = "play.wrappers.${name}: Either 'command' or 'package' must be specified when enabled";
}) cfg;
}; };
} }

View file

@ -1,3 +1,5 @@
# Steam module with gaming optimizations
# Automatically includes proton-cachyos package
{ {
pkgs, pkgs,
lib, lib,
@ -8,9 +10,12 @@
let let
cfg = config.play.steam; cfg = config.play.steam;
# Import proton-cachyos package directly
proton-cachyos = pkgs.callPackage ../../pkgs/proton-cachyos { };
# Default compatibility packages # Default compatibility packages
defaultCompatPackages = with pkgs; [ defaultCompatPackages = [
proton-ge-custom pkgs.proton-ge-custom
proton-cachyos proton-cachyos
]; ];