Steam/zh: Difference between revisions

Ardenet (talk | contribs)
Created page with "此外,在 Steam 中配置游戏启动选项时,可能需要使用参数 <code>--hdr-debug-force-output</code> 以在 gamescope 中强制启用 HDR(参考以下示例)。"
Tags: Mobile edit Mobile web edit
Ardenet (talk | contribs)
No edit summary
 
(31 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<div lang="en" dir="ltr" class="mw-content-ltr">
[https://store.steampowered.com/ Steam] 是一个数字游戏发行平台,提供庞大的游戏库供用户购买、下载和管理。在 NixOS 系统上,Steam 通常易于安装和使用,很多时候都能“开箱即用”。它通过兼容层 [[#Proton|Proton]] 支持在 Linux 上运行许多 Windows 游戏。<ref>https://store.steampowered.com/</ref>
[https://store.steampowered.com/ Steam] is a digital distribution platform for video games, offering a vast library for purchase, download, and management. On NixOS, Steam is generally easy to install and use, often working "out-of-the-box". It supports running many Windows games on Linux through its compatibility layer, [[#Proton|Proton]].<ref>https://store.steampowered.com/</ref>
</div>


<span id="Installation"></span>
<span id="Installation"></span>
Line 21: Line 19:
==== 系统设置 ====
==== 系统设置 ====


要安装 [[Steam]] 软件包并启用所有必要的系统选项以使其运行,请将以下内容添加到您的系统配置中:
要安装 [[Special:MyLanguage/Steam|Steam]] 软件包并启用所有必要的系统选项以使其运行,请将以下内容添加到您的系统配置中:


 
{{file|3=<nowiki>
{{file|/etc/nixos/configuration.nix|nix|
<nowiki>
programs.steam = {
programs.steam = {
   enable = true;
   enable = true;
Line 32: Line 28:
# Optional: If you encounter amdgpu issues with newer kernels (e.g., 6.10+ reported issues),
# Optional: If you encounter amdgpu issues with newer kernels (e.g., 6.10+ reported issues),
# you might consider using the LTS kernel or a known stable version.
# you might consider using the LTS kernel or a known stable version.
# boot.kernelPackages = pkgs.linuxPackages_lts; # Example for LTS
# boot.kernelPackages = pkgs.linuxPackages; # Example for LTS
</nowiki>
</nowiki>|name=/etc/nixos/configuration.nix|lang=nix}}
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
[https://news.ycombinator.com/item?id=41549030 关于内核 6.10 问题的轶事]
[https://news.ycombinator.com/item?id=41549030 Anecdata on kernel 6.10 issues]
 
</div>
{{note|1=启用 [[Special:MyLanguage/Steam|Steam]] 会安装多个[[Special:MyLanguage/unfree software|非自由软件包]]。如果您使用了 <code>allowUnfreePredicate</code>,则需要确保您的配置允许安装所有这些软件包。


{{note|<span lang="en" dir="ltr" class="mw-content-ltr">Enabling [[steam]] installs several [[unfree software|unfree packages]]. If you are using <code>allowUnfreePredicate</code> you will need to ensure that your configurations permit all of them.</span>
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
   nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
   nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
Line 46: Line 40:
     "steam-unwrapped"
     "steam-unwrapped"
   ];
   ];
</syntaxhighlight>
</syntaxhighlight>}}
}}


<span id="Configuration"></span>
<span id="Configuration"></span>
Line 54: Line 47:
基本 Steam 功能可以直接在 {{nixos:option|programs.steam}} 属性集中启用:
基本 Steam 功能可以直接在 {{nixos:option|programs.steam}} 属性集中启用:


{{file|/etc/nixos/configuration.nix|nix|
{{file|3=<nowiki>
<nowiki>
programs.steam = {
programs.steam = {
   enable = true; # Master switch, already covered in installation
   enable = true; # Master switch, already covered in installation
Line 62: Line 54:
   # Other general flags if available can be set here.
   # Other general flags if available can be set here.
};
};
# Tip: For improved gaming performance, you can also enable GameMode:
</nowiki>|name=/etc/nixos/configuration.nix|lang=nix}}
# programs.gamemode.enable = true;
 
</nowiki>
{{note|如果您使用的是 Steam 控制器或 Valve Index,Steam 硬件支持会通过设置 <code>programs.steam.enable {{=}} true;</code> 将 {{nixos:option|hardware.steam-hardware.enable}} 选项同步设置为 true 来隐性启用}}
}}


{{note|如果您使用的是 Steam 控制器或 Valve Index,Steam 支持会通过设置 <code>programs.steam.enable {{=}} true;</code> 将{{nixos:option|hardware.steam-hardware.enable}} 选项同步设置为 true 来隐性启用}}
{{note|如果您使用的是 2026 年发布的 Steam 控制器,Steam 客户端需要额外依赖 hidapi 才能与控制器正确通信。如果您反复遇到固更新失败的错误,这很可能是原因所在。您可以像这样直接将依赖项添加到 Steam 环境中:<code>programs.steam.extraPackages {{=}} [pkgs.hidapi];</code>}}


<span id="Tips_and_tricks"></span>
<span id="Tips_and_tricks"></span>
== 提示和技巧 ==
== 提示和技巧 ==
<span id="Improving_Performance"></span>
=== 提升性能 ===
您可以使用 [https://github.com/FeralInteractive/gamemode GameMode],这是一个针对 Linux 的库和守护程序组合,它允许游戏请求将一组优化指令以临时应用于主机操作系统和/或游戏进程。
<syntaxhighlight lang="nixos">
programs.gamemode.enable = true;
</syntaxhighlight>


<span id="Gamescope_Compositor_/_&quot;Boot_to_Steam_Deck&quot;"></span>
<span id="Gamescope_Compositor_/_&quot;Boot_to_Steam_Deck&quot;"></span>
Line 114: Line 114:
=== Gamescope HDR ===
=== Gamescope HDR ===


要使 HDR 在 gamescope 中工作,您需要启用 <code>gamescope</code> 程序的同时,单独安装 <code>gamescope-wsi</code> 软件包
要使 HDR 在 gamescope 中工作,您可能需要单独启用 <code>enableWsi</code> 选项


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">programs.gamescope = {
programs.gamescope = {
   enable = true;
   enable = true;
  enableWsi = true;
   capSysNice = false;
   capSysNice = false;
};
};</syntaxhighlight>
environment.systemPackages = with pkgs; [
  gamescope-wsi # HDR won't work without this
];
</syntaxhighlight>


此外,在 Steam 中配置游戏启动选项时,可能需要使用参数 <code>--hdr-debug-force-output</code> 以在 gamescope 中强制启用 HDR(参考以下示例)。
此外,在 Steam 中配置游戏启动选项时,可能需要使用参数 <code>--hdr-debug-force-output</code> 以在 gamescope 中强制启用 HDR(参考以下示例)。
Line 141: Line 137:
</syntaxhighlight>
</syntaxhighlight>


然后安装并运行 `steam-tui`。如果 `steam-tui` 出现问题,您可能需要先在 `steamcmd` 中登录:
然后安装并运行 <code>steam-tui</code>。如果 <code>steamcmd</code> 出现问题,您可能需要先在 <code>steam-tui</code> 中登录:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 236: Line 232:
=== 修复 GNOME Dock 栏和活动概览中游戏图标缺失的问题 ===
=== 修复 GNOME Dock 栏和活动概览中游戏图标缺失的问题 ===


<div lang="en" dir="ltr" class="mw-content-ltr">
GNOME 使用窗口类来确定与窗口关联的图标。Steam 目前在其 .desktop 文件中没有设置所需的键值<ref>https://github.com/ValveSoftware/steam-for-linux/issues/12207</ref>,但您可以通过编辑每个游戏的 .desktop 文件中的 <code>StartupWMClass</code> 键值来手动修复此问题,该文件位于 <code>~/.local/share/applications/</code> 目录下。
GNOME uses the window class to determine the icon associated with a window. Steam currently doesn't set the required key for this in its .desktop files<ref>https://github.com/ValveSoftware/steam-for-linux/issues/12207</ref>, but you can fix this manually by editing the <code>StartupWMClass</code> key for each game's .desktop file, found under <code>~/.local/share/applications/</code>.
 
</div>
对于通过 Proton 运行的游戏,该值应为 <code>steam_app_<game_id></code> (<code><game_id></code>与 <code>Exec</code> 行中 steam://rungameid/ 之后的值匹配)。使用 [[Special:MyLanguage/Home Manager|Home Manager]](每次重建时执行)自动执行此操作:


对于通过 Proton 运行的游戏,该值应为 <code>steam_app_<game_id></code> (在哪里<code><game_id></code>与 <code>Exec</code> 行中 steam://rungameid/ 之后的值匹配)。
<syntaxhighlight lang="nix">
home.activation.fixSteamIcons = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
  for f in ~/.local/share/applications/*.desktop; do
    id=$(grep -Eo 'steam://rungameid/[0-9]+' "$f" | sed 's#.*/##') || true
    [ -n "$id" ] || continue
    last=$(tail -n1 "$f" || true)
    want="StartupWMClass=steam_app_$id"
    [ "$last" = "$want" ] || echo "$want" >> "$f"
  done
'';
</syntaxhighlight>


对于原生运行的游戏,该值应与游戏的主可执行文件匹配。
对于原生运行的游戏,该值应与游戏的主可执行文件匹配。
Line 266: Line 272:
=== Steam 无法启动。我该怎么办? ===
=== Steam 无法启动。我该怎么办? ===


<div lang="en" dir="ltr" class="mw-content-ltr">
至少在 <code>x86-64</code> 平台上,导致 Steam 无法启动的一个常见问题是未在  <code>/etc/nixos/hardware-configuration.nix</code> 文件中启用以下选项:
One common issue preventing steam from being able to start, at least on <code>x86-64</code> platforms, is not having the following options enabled in your <code>/etc/nixos/hardware-configuration.nix</code>:
</div>


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 277: Line 281:
</syntaxhighlight>
</syntaxhighlight>


<div class="mw-translate-fuzzy">
如果您已设置这些选项(或者 32 位不适用于您的系统/平台),但仍然无法运行 Steam,请在终端运行 <code>strace steam -dev -console 2> steam.logs</code> 命令。如果未安装 <code>strace</code> ,请使用 <code>nix-shell -p strace</code> 或 <code>nix run nixpkgs#strace -- steam -dev -console 2> steam.logs</code> (如果使用 Flakes 版本)临时安装。之后,请提交错误报告。
在终端运行 <code>strace steam -dev -console 2> steam.logs</code> 命令。如果未安装 <code>strace</code> ,请使用 <code>nix-shell -p strace</code> 或 <code>nix run nixpkgs#strace -- steam -dev -console 2> steam.logs</code> (如果使用 Flakes 版本)临时安装。之后,请提交错误报告。
</div>


<span id="Steam_is_not_updated"></span>
<span id="Steam_is_not_updated"></span>
=== Steam 未更新 ===
=== Steam 未更新 ===


<div lang="en" dir="ltr" class="mw-content-ltr">
更新后重启 Steam 时,它会启动旧版本。([https://github.com/NixOS/nixpkgs/issues/181904 #181904])
When you restart [[Steam]] after an update, it starts the old version. ([https://github.com/NixOS/nixpkgs/issues/181904 #181904])
一个解决方法是删除 <code>/home/&lt;USER&gt;/.local/share/Steam/userdata</code> 目录下的用户文件。您可以在终端中使用 <code>rm -rf /home/&lt;USER&gt;/.local/share/Steam/userdata</code> 命令或文件管理器来完成此操作。之后,重启 Steam 即可重新生成配置。
A workaround is to remove the user files in <code>/home/&lt;USER&gt;/.local/share/Steam/userdata</code>. This can be done with <code>rm -rf /home/&lt;USER&gt;/.local/share/Steam/userdata</code> in the terminal or with your file manager. After that, Steam can be set up again by restarting.
</div>


<span id="Game_fails_to_start"></span>
<span id="Game_fails_to_start"></span>
Line 303: Line 303:
注意:如果游戏卡在“正在安装脚本”界面,请检查是否存在 DXSETUP.EXE 进程并手动运行它,然后重新启动游戏。
注意:如果游戏卡在“正在安装脚本”界面,请检查是否存在 DXSETUP.EXE 进程并手动运行它,然后重新启动游戏。


<span id="Changing_the_driver_on_AMD_GPUs"></span>
<span id="Changing_the_driver_on_AMD_GPUs_<!-- this is not recommended due radv drivers performing better and generally more stable than amdvlk. My suggestion remove this section. source: https://forums.guru3d.com/threads/the-mesa-radv-amdvlk-thread.449774/ -->"></span>
==== 更改 AMD GPU 的驱动程序 ====
==== 更改 AMD GPU 的驱动程序 <!-- this is not recommended due radv drivers performing better and generally more stable than amdvlk. My suggestion remove this section. source: https://forums.guru3d.com/threads/the-mesa-radv-amdvlk-thread.449774/ -->====


{{note|<span lang="en" dir="ltr" class="mw-content-ltr">This is not recommended because radv drivers tend to perform better and are generally more stable than amdvlk.</span>}}
{{note|不建议这样做,因为 radv 驱动程序往往性能更好,而且通常比 amdvlk 驱动程序更稳定。}}


有时,更换 AMD GPU 的驱动程序会有帮助。要尝试此方法,首先,安装多个驱动程序,例如 radv 和 amdvlk:
有时,更换 AMD GPU 的驱动程序会有帮助。要尝试此方法,首先,安装多个驱动程序,例如 radv 和 amdvlk:
Line 321: Line 321:
</syntaxhighlight>
</syntaxhighlight>


如果两个驱动程序都存在,[[Steam]] 将默认使用 amdvlk。amdvlk 驱动程序在 Vulkan 规范实现方面更准确,但性能不如 radv。然而,这种在正确性和性能之间的权衡有时会直接影响游戏体验。
如果两个驱动程序都存在,[[Special:MyLanguage/Steam|Steam]] 将默认使用 amdvlk。amdvlk 驱动程序在 Vulkan 规范实现方面更准确,但性能不如 radv。然而,这种在正确性和性能之间的权衡有时会直接影响游戏体验。


如果同时安装了 radv 和 amdvlk,要将驱动程序“重置”为 radv,请设置环境变量 <code>AMD_VULKAN_ICD = "RADV"</code> 或 <code>VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json"</code> 。例如,如果您从 shell 启动 Steam,则可以通过运行 <code>AMD_VULKAN_ICD="RADV" steam</code> 为当前会话启用 radv。如果您不确定当前使用的是哪个驱动程序,可以启动一个启用了 MangoHud 的游戏,MangoHud 可以显示当前正在使用的驱动程序。
如果同时安装了 radv 和 amdvlk,要将驱动程序“重置”为 radv,请设置环境变量 <code>AMD_VULKAN_ICD = "RADV"</code> 或 <code>VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json"</code> 。例如,如果您从 shell 启动 Steam,则可以通过运行 <code>AMD_VULKAN_ICD="RADV" steam</code> 为当前会话启用 radv。如果您不确定当前使用的是哪个驱动程序,可以启动一个启用了 [https://github.com/flightlessmango/MangoHud MangoHud] 的游戏,MangoHud 可以显示当前正在使用的驱动程序。


=== SteamVR ===
=== SteamVR ===
Line 333: Line 333:
=== 与 Steam 使用时 Gamescope 无法启动 ===
=== 与 Steam 使用时 Gamescope 无法启动 ===


<div lang="en" dir="ltr" class="mw-content-ltr">
Gamescope 可能由于缺少 Xorg 库而无法启动。([https://github.com/NixOS/nixpkgs/issues/214275 #214275]) 要解决此问题,请添加以下内容覆盖 steam 包:
Gamescope may fail to start due to missing Xorg libraries. ([https://github.com/NixOS/nixpkgs/issues/214275 #214275]) To resolve this override the steam package to add them:
</div>


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 356: Line 354:


<span id="Udev_rules_for_additional_Gamepads"></span>
<span id="Udev_rules_for_additional_Gamepads"></span>
=== 额外游戏手柄的 udev 规则 ===
=== 用于额外支持游戏手柄的 udev 规则 ===


<div lang="en" dir="ltr" class="mw-content-ltr">
在某些特定情况下,游戏手柄可能需要一些额外的配置才能正常工作,这些配置以 udev 规则的形式表示。这可以通过 <code>services.udev.extraRules</code> 来配置。
In specific scenarios gamepads, might require some additional configuration in order to function properly in the form of udev rules. This can be achieved with <code>services.udev.extraRules</code>.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
以下示例适用于 8bitdo Ultimate 蓝牙控制器,不同的控制器需要知道设备的供应商和产品 ID
The following example is for the 8bitdo Ultimate Bluetooth controller, different controllers will require knowledge of the vendor and product ID for the device:
</div>


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 372: Line 366:
</syntaxhighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
要查找设备的供应商和产品 ID[https://search.nixos.org/packages?channel=unstable&show=usbutils&from=0&size=50&sort=relevance&type=packages&query=usbutils usbutils] 可能有用。
To find the vendor and product ID of a device [https://search.nixos.org/packages?channel=unstable&show=usbutils&from=0&size=50&sort=relevance&type=packages&query=usbutils usbutils] might be useful
 
</div>
<span id="Steam_controller_mouse_input_issues"></span>
=== Steam 控制器的鼠标输入问题 ===
 
使用控制器进行鼠标输入时,可能无法控制视觉光标。在这种情况下,输入仍然会被识别,但光标不会移动。解决方法是使用 extest 预加载 Steam。Steam 安装包中已经提供了相应的选项:
 
<syntaxhighlight lang="nix">
  programs.steam = {
    extest.enable = true;
  };
</syntaxhighlight>


<span id="Known_issues"></span>
<span id="Known_issues"></span>
=== 已知问题 ===
=== 已知问题 ===


<div lang="en" dir="ltr" class="mw-content-ltr">
“Project Zomboid”可能会报告“无法确定Java是32位还是64位”。这与Java本身无关,是由其使用自身过时的Java二进制文件解析路径时,其中包含非拉丁字符导致的。请通过在<code>steam-run bash</code>中直接启动本地Java二进制文件来解决错误。
"Project Zomboid" may report "couldn't determine 32/64 bit of java". This is not related to java at all, it carries its own outdated java binary that refuses to start if path contains non-Latin characters. Check for errors by directly starting local java binary within <code>steam-run bash</code>.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
通过 [[Special:MyLanguage/Steam|Steam]] 应用重置密码可能会反复在验证码环节失败,即使验证码界面显示成功,[[Special:MyLanguage/Steam|Steam]] 本身也会提示验证码错误。通过 [[Special:MyLanguage/Steam|Steam]] 网站重置密码应该可以解决这个问题。
Resetting your password through the [[Steam]] app may fail at the CAPTCHA step repeatedly, with [[Steam]] itself reporting that the CAPTCHA was not correct, even though the CAPTCHA UI shows success. Resetting password through the [[Steam]] website should work around that.
</div>


<span id="References"></span>
<span id="References"></span>