feat: gaming (#223)

* refactor: configure gaming suite via options, use pkgs-x64
* fix: gaming on apple silicon (not work yet)
This commit is contained in:
Ryan Yin
2025-09-17 13:54:27 +08:00
committed by GitHub
parent 35f9816db9
commit 070aeae8db
8 changed files with 191 additions and 125 deletions

View File

@@ -1,48 +1,71 @@
{ pkgs, osConfig, ... }:
{
# ==========================================================================
# Other Optimizations
# Usage:
# Lutris - enable advanced options, go to the System options -> Command prefix, add: `mangohud`
# Steam - add this as a launch option: `mangohud %command%` / `gamemoderun %command%`
# ==========================================================================
pkgs,
pkgs-x64,
osConfig,
config,
lib,
...
}:
with lib;
let
cfg = config.modules.desktop.gaming;
in
{
options.modules.desktop = {
gaming = {
enable = mkEnableOption "Install Game Suite(steam, lutris, etc)";
};
};
home.packages = with pkgs; [
# https://github.com/flightlessmango/MangoHud
# a simple overlay program for monitoring FPS, temperature, CPU and GPU load, and more.
mangohud
# a game launcher - great for epic games and gog games
(heroic.override {
extraPkgs = pkgs: [
pkgs.gamescope
config = mkIf cfg.enable {
# ==========================================================================
# Other Optimizations
# Usage:
# Lutris - enable advanced options, go to the System options -> Command prefix, add: `mangohud`
# Steam - add this as a launch option: `mangohud %command%` / `gamemoderun %command%`
# ==========================================================================
home.packages =
(with pkgs; [
# https://github.com/flightlessmango/MangoHud
# a simple overlay program for monitoring FPS, temperature, CPU and GPU load, and more.
mangohud
# GUI for installing custom Proton versions like GE_Proton
# proton - a Wine distribution aimed at gaming
protonplus
# Script to install various redistributable runtime libraries in Wine.
winetricks
# https://github.com/Open-Wine-Components/umu-launcher
# a unified launcher for Windows games on Linux
umu-launcher
])
++ (with pkgs-x64; [
# a game launcher - great for epic games and gog games
(heroic.override {
extraPkgs = _pkgs: [
pkgs.gamescope # aarch64
];
})
]);
# a GUI game launcher for Steam/GoG/Epic
programs.lutris = {
enable = true;
defaultWinePackage = pkgs-x64.proton-ge-bin;
steamPackage = osConfig.programs.steam.package;
protonPackages = [ pkgs-x64.proton-ge-bin ];
winePackages = with pkgs-x64; [
wineWow64Packages.full
wineWowPackages.stagingFull
];
})
# GUI for installing custom Proton versions like GE_Proton
# proton - a Wine distribution aimed at gaming
protonplus
# Script to install various redistributable runtime libraries in Wine.
winetricks
# https://github.com/Open-Wine-Components/umu-launcher
# a unified launcher for Windows games on Linux
umu-launcher
];
# a GUI game launcher for Steam/GoG/Epic
programs.lutris = {
enable = true;
defaultWinePackage = pkgs.proton-ge-bin;
steamPackage = osConfig.programs.steam.package;
protonPackages = [ pkgs.proton-ge-bin ];
winePackages = with pkgs; [
wineWow64Packages.full
wineWowPackages.stagingFull
];
extraPackages = with pkgs; [
winetricks
gamescope
gamemode
mangohud
umu-launcher
];
extraPackages = with pkgs; [
winetricks
gamescope
gamemode
mangohud
umu-launcher
];
};
};
}

View File

@@ -1,5 +1,6 @@
{
pkgs,
pkgs-x64,
pkgs-unstable,
nur-ryan4yin,
...
@@ -21,10 +22,8 @@
vulkan-tools
glxinfo
nvitop
]
++ (lib.optionals pkgs.stdenv.isx86_64 [
(zoom-us.override { hyprlandXdgDesktopPortalSupport = true; })
]);
(pkgs-x64.zoom-us.override { hyprlandXdgDesktopPortalSupport = true; })
];
programs.mpv = {
enable = true;

View File

@@ -9,6 +9,13 @@
nixos-apple-silicon.nixosModules.default
];
environment.systemPackages = with pkgs-unstable; [
box64 # Linux Userspace x86 and x86_64 Emulator, run x86_64 apps(such as games, gui apps) on aarch64.
# https://asahilinux.org/2024/12/muvm-x11-bridging/
# https://github.com/nix-community/nixos-apple-silicon/issues/237
muvm # run x86_64 Apps/Games in a microVM, used as a workaround of apple silicon's 16k page size.
];
networking.wireless.iwd = {
enable = true;
settings.General.EnableNetworkConfiguration = true;

View File

@@ -19,7 +19,6 @@ in
./hardware-configuration.nix
./nvidia.nix
./ai
./gaming.nix
./preservation.nix
./secureboot.nix

View File

@@ -1,64 +0,0 @@
{
pkgs,
nix-gaming,
aagl,
...
}:
{
# ==========================================================================
# Gaming on Linux
#
# <https://www.protondb.com/> can give you an idea what works where and how.
# Begineer Guide: <https://www.reddit.com/r/linux_gaming/wiki/faq/>
# ==========================================================================
# Games installed by Steam works fine on NixOS, no other configuration needed.
programs.steam = {
# Some location that should be persistent:
# ~/.local/share/Steam - The default Steam install location
# ~/.local/share/Steam/steamapps/common - The default Game install location
# ~/.steam/root - A symlink to ~/.local/share/Steam
# ~/.steam - Some Symlinks & user info
enable = pkgs.stdenv.isx86_64;
# https://github.com/ValveSoftware/gamescope
# Run a GameScope driven Steam session from your display-manager
# fix resolution upscaling and stretched aspect ratios
gamescopeSession.enable = true;
# https://github.com/Winetricks/winetricks
# Whether to enable protontricks, a simple wrapper for running Winetricks commands for Proton-enabled games.
protontricks.enable = true;
# Whether to enable Load the extest library into Steam, to translate X11 input events to uinput events (e.g. for using Steam Input on Wayland) .
extest.enable = true;
fontPackages = [
pkgs.wqy_zenhei # Need by steam for Chinese
];
};
# see https://github.com/fufexan/nix-gaming/#pipewire-low-latency
services.pipewire.lowLatency.enable = true;
programs.steam.platformOptimizations.enable = true;
imports = with nix-gaming.nixosModules; [
pipewireLowLatency
platformOptimizations
# run anime games on Linux
aagl.nixosModules.default
];
# Optimise Linux system performance on demand
# https://github.com/FeralInteractive/GameMode
# https://wiki.archlinux.org/title/Gamemode
#
# Usage:
# 1. For games/launchers which integrate GameMode support:
# https://github.com/FeralInteractive/GameMode#apps-with-gamemode-integration
# simply running the game will automatically activate GameMode.
programs.gamemode.enable = pkgs.stdenv.isx86_64;
# run anime games on Linux
# https://github.com/an-anime-team/
programs.anime-game-launcher.enable = true; # Genshin: Impact
programs.honkers-railway-launcher.enable = true; # Honkai: Star Rail
programs.honkers-launcher.enable = false; # Honkai: Impact 3
programs.sleepy-launcher.enable = false; # Zenless Zon Zero
}

View File

@@ -0,0 +1,84 @@
{
pkgs,
pkgs-x64,
nix-gaming,
aagl,
config,
lib,
...
}:
with lib;
let
cfg = config.modules.desktop.gaming;
in
{
imports = [
nix-gaming.nixosModules.pipewireLowLatency
nix-gaming.nixosModules.platformOptimizations
# run anime games on Linux
aagl.nixosModules.default
];
options.modules.desktop = {
gaming = {
enable = mkEnableOption "Install Game Suite(steam, lutris, etc)";
};
};
config = mkIf cfg.enable {
# ==========================================================================
# Gaming on Linux
#
# <https://www.protondb.com/> can give you an idea what works where and how.
# Begineer Guide: <https://www.reddit.com/r/linux_gaming/wiki/faq/>
# ==========================================================================
# Games installed by Steam works fine on NixOS, no other configuration needed.
# https://github.com/NixOS/nixpkgs/blob/master/doc/packages/steam.section.md
programs.steam = {
# Some location that should be persistent:
# ~/.local/share/Steam - The default Steam install location
# ~/.local/share/Steam/steamapps/common - The default Game install location
# ~/.steam/root - A symlink to ~/.local/share/Steam
# ~/.steam - Some Symlinks & user info
enable = true;
package = pkgs-x64.steam;
# https://github.com/ValveSoftware/gamescope
# Run a GameScope driven Steam session from your display-manager
# fix resolution upscaling and stretched aspect ratios
gamescopeSession.enable = true;
# https://github.com/Winetricks/winetricks
# Whether to enable protontricks, a simple wrapper for running Winetricks commands for Proton-enabled games.
protontricks.enable = true;
# Whether to enable Load the extest library into Steam, to translate X11 input events to uinput events (e.g. for using Steam Input on Wayland) .
extest.enable = true;
fontPackages = [
pkgs.wqy_zenhei # Need by steam for Chinese
];
};
# see https://github.com/fufexan/nix-gaming/#pipewire-low-latency
services.pipewire.lowLatency.enable = true;
programs.steam.platformOptimizations.enable = true;
# Optimise Linux system performance on demand
# https://github.com/FeralInteractive/GameMode
# https://wiki.archlinux.org/title/Gamemode
#
# Usage:
# 1. For games/launchers which integrate GameMode support:
# https://github.com/FeralInteractive/GameMode#apps-with-gamemode-integration
# simply running the game will automatically activate GameMode.
programs.gamemode.enable = true;
# run anime games on Linux
# https://github.com/an-anime-team/r
networking.mihoyo-telemetry.block = true;
environment.systemPackages = with aagl.packages."x86_64-linux"; [
anime-game-launcher # Genshin: Impact
honkers-railway-launcher # Honkai: Star Rail
sleepy-launcher # Zenless Zon Zero
];
};
}

View File

@@ -33,14 +33,23 @@ let
modules.desktop.wayland.enable = true;
modules.secrets.desktop.enable = true;
modules.secrets.preservation.enable = true;
# not supported yet
modules.desktop.gaming.enable = false;
}
];
home-modules =
(map mylib.relativeToRoot [
# common
"home/linux/gui.nix"
# host specific
"hosts/12kingdoms-${name}/home.nix"
])
++ [
{
# not supported yet
modules.desktop.gaming.enable = false;
}
];
home-modules = map mylib.relativeToRoot [
# common
"home/linux/gui.nix"
# host specific
"hosts/12kingdoms-${name}/home.nix"
];
};
modules-hyprland = {
@@ -48,7 +57,9 @@ let
]
++ base-modules.nixos-modules;
home-modules = [
{ modules.desktop.hyprland.enable = true; }
{
modules.desktop.hyprland.enable = true;
}
]
++ base-modules.home-modules;
};

View File

@@ -34,14 +34,21 @@ let
modules.desktop.wayland.enable = true;
modules.secrets.desktop.enable = true;
modules.secrets.preservation.enable = true;
modules.desktop.gaming.enable = true;
}
];
home-modules =
(map mylib.relativeToRoot [
# common
"home/linux/gui.nix"
# host specific
"hosts/idols-${name}/home.nix"
])
++ [
{
modules.desktop.gaming.enable = true;
}
];
home-modules = map mylib.relativeToRoot [
# common
"home/linux/gui.nix"
# host specific
"hosts/idols-${name}/home.nix"
];
};
modules-hyprland = {