189 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			189 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			Nix
		
	
	
	
	
	
{ 
 | 
						|
  config,
 | 
						|
  lib,
 | 
						|
  pkgs,
 | 
						|
  aagl,
 | 
						|
  ...
 | 
						|
}: let
 | 
						|
  cfg = config.gaming;
 | 
						|
in {
 | 
						|
  imports = [ aagl.nixosModules.default ];
 | 
						|
 | 
						|
  options.gaming = {
 | 
						|
    steam = {
 | 
						|
      enable = lib.mkEnableOption "Steam gaming platform";
 | 
						|
 | 
						|
      firewall = {
 | 
						|
        remotePlay = lib.mkOption {
 | 
						|
          type = lib.types.bool;
 | 
						|
          default = true;
 | 
						|
          description = "Open firewall ports for Steam Remote Play";
 | 
						|
        };
 | 
						|
 | 
						|
        localNetworkGameTransfers = lib.mkOption {
 | 
						|
          type = lib.types.bool;
 | 
						|
          default = true;
 | 
						|
          description = "Open firewall ports for local network game transfers";
 | 
						|
        };
 | 
						|
      };
 | 
						|
    };
 | 
						|
 | 
						|
    gamemode = {
 | 
						|
      enable = lib.mkEnableOption "Gamemode performance optimization";
 | 
						|
      config = lib.mkOption {
 | 
						|
        type = lib.types.attrs;
 | 
						|
        default = {};
 | 
						|
        description = "Custom Gamemode configuration options";
 | 
						|
      };
 | 
						|
    };
 | 
						|
 | 
						|
    gamescope = {
 | 
						|
      enable = lib.mkEnableOption "Gamescope gaming compositor";
 | 
						|
      settings = {
 | 
						|
        resolution = lib.mkOption {
 | 
						|
          type = lib.types.nullOr (lib.types.submodule {
 | 
						|
            options = {
 | 
						|
              width = lib.mkOption {
 | 
						|
                type = lib.types.int;
 | 
						|
                description = "Gamescope rendering width";
 | 
						|
              };
 | 
						|
              height = lib.mkOption {
 | 
						|
                type = lib.types.int;
 | 
						|
                description = "Gamescope rendering height";
 | 
						|
              };
 | 
						|
            };
 | 
						|
          });
 | 
						|
          default = null;
 | 
						|
          description = "Gamescope rendering resolution";
 | 
						|
        };
 | 
						|
 | 
						|
        refreshRate = lib.mkOption {
 | 
						|
          type = lib.types.nullOr lib.types.int;
 | 
						|
          default = null;
 | 
						|
          description = "Gamescope rendering refresh rate";
 | 
						|
        };
 | 
						|
      };
 | 
						|
    };
 | 
						|
 | 
						|
    lutris = {
 | 
						|
      enable = lib.mkEnableOption "Lutris game manager and launcher";
 | 
						|
      package = lib.mkOption {
 | 
						|
        type = lib.types.package;
 | 
						|
        default = pkgs.lutris;
 | 
						|
        description = "Lutris package to use (allows for custom or alternative packages)";
 | 
						|
      };
 | 
						|
 | 
						|
      wine = {
 | 
						|
        enable = lib.mkEnableOption "Enable Wine support for Lutris";
 | 
						|
        package = lib.mkOption {
 | 
						|
          type = lib.types.package;
 | 
						|
          default = pkgs.wine-staging;
 | 
						|
          description = "Wine package to use with Lutris";
 | 
						|
        };
 | 
						|
      };
 | 
						|
 | 
						|
      # Compatibility layers for Lutris
 | 
						|
      compatibility = {
 | 
						|
        protonSupport = lib.mkOption {
 | 
						|
          type = lib.types.bool;
 | 
						|
          default = true;
 | 
						|
          description = "Enable Proton-like compatibility layers for Lutris";
 | 
						|
        };
 | 
						|
 | 
						|
        extraTools = lib.mkOption {
 | 
						|
          type = lib.types.listOf lib.types.package;
 | 
						|
          default = [];
 | 
						|
          description = "Additional compatibility tools for Lutris";
 | 
						|
        };
 | 
						|
      };
 | 
						|
 | 
						|
      # Additional system packages for Lutris
 | 
						|
      extraPackages = lib.mkOption {
 | 
						|
        type = lib.types.listOf lib.types.package;
 | 
						|
        default = [];
 | 
						|
        description = "Additional packages to install alongside Lutris";
 | 
						|
      };
 | 
						|
    };
 | 
						|
 | 
						|
    minecraft = {
 | 
						|
      enable = lib.mkEnableOption "Minecraft in the form of PrismLauncher, a tool for launching Minecraft";
 | 
						|
    };
 | 
						|
    ffxiv = {
 | 
						|
      enable = lib.mkEnableOption "Final Fantasy XIV and it's accompanied (unofficial) launcher";
 | 
						|
    };
 | 
						|
 | 
						|
    aagl = {
 | 
						|
      anime-game-launcher = {
 | 
						|
        enable = lib.mkEnableOption "AAGL (legacy)";
 | 
						|
      };
 | 
						|
 | 
						|
      honkers-railway-launcher = {
 | 
						|
        enable = lib.mkEnableOption "Honkai: Star Rail launcher";
 | 
						|
      };
 | 
						|
    };
 | 
						|
  };
 | 
						|
 | 
						|
  config = {
 | 
						|
    programs.steam = lib.mkIf cfg.steam.enable {
 | 
						|
      enable = true;
 | 
						|
      remotePlay.openFirewall = cfg.steam.firewall.remotePlay;
 | 
						|
      localNetworkGameTransfers.openFirewall = cfg.steam.firewall.localNetworkGameTransfers;
 | 
						|
    };
 | 
						|
 | 
						|
    programs.gamemode = lib.mkIf cfg.gamemode.enable {
 | 
						|
      enable = true;
 | 
						|
      settings = cfg.gamemode.config;
 | 
						|
    };
 | 
						|
 | 
						|
    programs.gamescope = lib.mkIf cfg.gamescope.enable {
 | 
						|
      enable = true;
 | 
						|
 | 
						|
      # Apply custom resolution if specified
 | 
						|
      args =
 | 
						|
        lib.optional (cfg.gamescope.settings.resolution != null) [
 | 
						|
          "-w"
 | 
						|
          (toString cfg.gamescope.settings.resolution.width)
 | 
						|
          "-h"
 | 
						|
          (toString cfg.gamescope.settings.resolution.height)
 | 
						|
        ]
 | 
						|
        ++ lib.optional (cfg.gamescope.settings.refreshRate != null) [
 | 
						|
          "-r"
 | 
						|
          (toString cfg.gamescope.settings.refreshRate)
 | 
						|
        ];
 | 
						|
    };
 | 
						|
 | 
						|
    programs.anime-game-launcher = lib.mkIf cfg.aagl.anime-game-launcher.enable {
 | 
						|
      enable = true;
 | 
						|
    };
 | 
						|
 | 
						|
    programs.honkers-railway-launcher = lib.mkIf cfg.aagl.honkers-railway-launcher.enable {
 | 
						|
      enable = true;
 | 
						|
    };
 | 
						|
 | 
						|
    environment.systemPackages =
 | 
						|
      (lib.optionals cfg.lutris.enable (
 | 
						|
        [cfg.lutris.package] ++
 | 
						|
        (lib.optionals cfg.lutris.wine.enable [
 | 
						|
          cfg.lutris.wine.package
 | 
						|
          pkgs.winetricks
 | 
						|
        ]) ++
 | 
						|
        (lib.optionals cfg.lutris.compatibility.protonSupport [
 | 
						|
          pkgs.protonup-ng
 | 
						|
          pkgs.protonup-qt
 | 
						|
        ]) ++
 | 
						|
        cfg.lutris.compatibility.extraTools ++
 | 
						|
        cfg.lutris.extraPackages
 | 
						|
      )) ++
 | 
						|
      (lib.optionals cfg.minecraft.enable [pkgs.prismlauncher]) ++
 | 
						|
      (lib.optionals cfg.ffxiv.enable [pkgs.xivlauncher]);
 | 
						|
 | 
						|
    nix.settings = (lib.mkIf
 | 
						|
      (cfg.aagl.anime-game-launcher.enable || cfg.aagl.honkers-railway-laucher.enable)
 | 
						|
      {
 | 
						|
        substituters = [ "https://ezkea.cachix.org" ];
 | 
						|
        trusted-public-keys = [ "ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI=" ];
 | 
						|
      }
 | 
						|
    );
 | 
						|
  };
 | 
						|
}
 |