refactor: steam (#217)

This commit is contained in:
Ryan Yin
2025-08-22 16:16:35 +08:00
committed by GitHub
parent 7a1a9644c6
commit 8e356dd6fc
6 changed files with 59 additions and 138 deletions

View File

@@ -1,13 +0,0 @@
{
pkgs,
nix-gaming,
...
}:
{
home.packages = with pkgs; [
# nix-gaming.packages.${pkgs.system}.osu-laser-bin
gamescope # SteamOS session compositing window manager
prismlauncher # A free, open source launcher for Minecraft
winetricks # A script to install DLLs needed to work around problems in Wine
];
}

View File

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

View File

@@ -1,4 +0,0 @@
{ mylib, ... }:
{
imports = mylib.scanPaths ./.;
}

View File

@@ -1,62 +0,0 @@
# https://github.com/fufexan/dotfiles/blob/483680e121b73db8ed24173ac9adbcc718cbbc6e/system/programs/gamemode.nix
{
config,
pkgs,
nix-gaming,
lib,
...
}:
let
programs = lib.makeBinPath [
config.programs.hyprland.package
pkgs.coreutils
pkgs.power-profiles-daemon
];
startscript = pkgs.writeShellScript "gamemode-start" ''
export PATH=$PATH:${programs}
export HYPRLAND_INSTANCE_SIGNATURE=$(ls -1 /tmp/hypr | tail -1)
hyprctl --batch 'keyword decoration:blur 0 ; keyword animations:enabled 0 ; keyword misc:vfr 0'
powerprofilesctl set performance
'';
endscript = pkgs.writeShellScript "gamemode-end" ''
export PATH=$PATH:${programs}
export HYPRLAND_INSTANCE_SIGNATURE=$(ls -1 /tmp/hypr | tail -1)
hyprctl --batch 'keyword decoration:blur 1 ; keyword animations:enabled 1 ; keyword misc:vfr 1'
powerprofilesctl set power-saver
'';
in
{
# 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.
# 2. For others, launching the game through gamemoderun: `gamemoderun ./game`
# 3. For steam: `gamemoderun steam-runtime`
programs.gamemode = {
enable = pkgs.stdenv.isx86_64;
settings = {
general = {
softrealtime = "auto";
renice = 15;
};
custom = {
start = startscript.outPath;
end = endscript.outPath;
};
};
};
# 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
];
}

View File

@@ -1,58 +0,0 @@
# https://github.com/fufexan/dotfiles/blob/483680e/system/programs/steam.nix
{ pkgs, ... }:
{
# https://wiki.archlinux.org/title/steam
# 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
# enables features such as resolution upscaling and stretched aspect ratios (such as 4:3)
gamescopeSession.enable = true;
# fix gamescope inside steam
package = pkgs.steam.override {
extraPkgs =
pkgs: with pkgs; [
xorg.libXcursor
xorg.libXi
xorg.libXinerama
xorg.libXScrnSaver
libpng
libpulseaudio
libvorbis
stdenv.cc.cc.lib
libkrb5
keyutils
# fix CJK fonts
source-sans
source-serif
source-han-sans
source-han-serif
# audio
pipewire
# other common
udev
alsa-lib
vulkan-loader
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr # To use the x11 feature
libxkbcommon
wayland # To use the wayland feature
];
};
};
fonts.packages = with pkgs; [
wqy_zenhei # Need by steam for Chinese
];
}

58
hosts/idols-ai/gaming.nix Normal file
View File

@@ -0,0 +1,58 @@
{ pkgs, nix-gaming, ... }:
{
# https://wiki.archlinux.org/title/steam
# 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
];
# ==========================================================================
# 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%`
# ==========================================================================
environment.systemPackages = with pkgs; [
# https://github.com/flightlessmango/MangoHud
# a simple overlay program for monitoring FPS, temperature, CPU and GPU load, and more.
mangohud
# a GUI game launcher for Steam/GoG/Epic
lutris
];
# 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;
}