Move steam config

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-07-26 10:30:39 +01:00
parent aaca09300e
commit d663b05527
3 changed files with 1 additions and 1 deletions

View File

@@ -0,0 +1,77 @@
{ user, home }:
{
config,
lib,
pkgs,
...
}:
{
environment.persistence."/persist/state" = {
"${home}/.steam" = { };
"${home}/.local/share/Steam" = { };
};
programs = {
steam = {
enable = true;
localNetworkGameTransfers.openFirewall = true;
extest.enable = true;
protontricks.enable = true;
extraCompatPackages = with pkgs; [ proton-ge-bin ];
};
gamescope = {
enable = true;
args = [
"--rt"
"-f"
];
};
gamemode.enable = true;
};
home-manager.users.${user}.systemd.user = {
services.steam-ln =
let
steamLn = lib.meta.getExe (
pkgs.writeShellApplication {
name = "steam-ln";
runtimeInputs = with pkgs; [ coreutils ];
text = builtins.readFile ./steam-ln.sh;
}
);
in
{
Unit = {
Description = "Sync Steam games with Games directory";
After = [
config.environment.persistence."/persist/state"."${home}/.local/share/Steam".mount
config.environment.persistence."/persist/user"."${home}/Games".mount
];
DefaultDependencies = false;
};
Service = {
ExecStart = steamLn;
Type = "oneshot";
};
Install.WantedBy = [ "default.target" ];
};
paths.steam-ln = {
Unit = {
Description = "Monitor Steam games directory for changes";
After = [
config.environment.persistence."/persist/state"."${home}/.local/share/Steam".mount
config.environment.persistence."/persist/user"."${home}/Games".mount
];
};
Path.PathChanged = "${home}/.local/share/Steam/steamapps/common";
Install.WantedBy = [ "default.target" ];
};
};
}

View File

@@ -0,0 +1,64 @@
# shellcheck shell=bash
shopt -s nullglob
STEAM="$HOME/.local/share/Steam/steamapps/common"
GAMES="$HOME/Games"
EXCLUDE=(
"Proton - Experimental"
"Proton Hotfix"
"SteamLinuxRuntime"
"SteamLinuxRuntime_soldier"
"SteamLinuxRuntime_sniper"
"Steamworks Shared"
"Steam.dll"
)
is_excluded() {
local dir=$1
for exclude in "${EXCLUDE[@]}"; do
if [[ "$dir" == "$exclude" ]]; then
return 0
fi
done
return 1
}
for game in "$STEAM"/*/; do
name=$(basename "$game")
if is_excluded "$name"; then
echo "Excluding $name from symlink creation."
continue
fi
if [[ -L "$GAMES/$name" ]]; then
continue
fi
if [[ -d "$GAMES/$name" || -f "$GAMES/$name" ]]; then
>&2 echo "Error: $name is already a regular directory or file."
continue
fi
echo "Creating symlink for $name..."
ln -srf "$game" "$GAMES/$name"
done
for link in "$GAMES"/*; do
target=$(readlink "$link")
if [[ ! "$target" == "$STEAM/"* ]]; then
continue
fi
name=$(basename "$target")
if [[ -e "$target" ]] && ! is_excluded "$name"; then
continue
fi
echo "Removing symlink $link..."
rm "$link"
done