{ config, lib, ... }:

with lib;

let
  cfg = config.settings.applications.steam;
in {
  options = {
    settings.applications.steam.enable = lib.mkOption {
      type = with lib.types; bool;
      description = ''
        Enable steam
      '';
    };
  };

  config = mkIf cfg.enable {
    nixpkgs.config.allowUnfree = true;
    nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
      "steam"
      "steam-original"
      "steam-run"
    ];

    programs.steam = {
      enable = true;
      remotePlay.openFirewall = true;
      dedicatedServer.openFirewall = true;
    };
  };
}