reformat komentarzy, i plik desktop

This commit is contained in:
Sasza Stanczew 2026-02-16 13:47:58 +01:00
parent 8d1f5e59c3
commit 6944ac33e3

View file

@ -1,7 +1,9 @@
{ config, pkgs, lib, ... }:
let
# Legacy libxml2 (2.9.x) — required by Tibia
# ────────────────────────────────────────────────────────────────
# Legacy libxml2 (2.9.x) — Tibia requires libxml2.so.2
# ────────────────────────────────────────────────────────────────
libxml2_2_9 = pkgs.stdenv.mkDerivation {
pname = "libxml2-2.9";
version = "2.9.14";
@ -22,28 +24,32 @@ let
enableParallelBuilding = true;
};
# ────────────────────────────────────────────────────────────────
# Centralized runtime library path for Tibia
tibiaLibPath =
lib.makeLibraryPath [
# ────────────────────────────────────────────────────────────────
tibiaLibPath = lib.makeLibraryPath [
pkgs.nss
pkgs.nspr
pkgs.libxkbfile
libxml2_2_9
];
# Helper: LD_LIBRARY_PATH export line
exportLibs = ''
export LD_LIBRARY_PATH="${tibiaLibPath}:$LD_LIBRARY_PATH"
'';
# Wrapper for the real client (system-wide)
# ────────────────────────────────────────────────────────────────
# System-wide wrapper for the Tibia client binary
# ────────────────────────────────────────────────────────────────
tibiaClientWrapper = pkgs.writeShellScriptBin "tibia-client" ''
#!/usr/bin/env bash
${exportLibs}
exec steam-run "$HOME/.local/share/CipSoft GmbH/Tibia/packages/Tibia/bin/client" "$@"
'';
# Patcher for Tibia's package.json
# ────────────────────────────────────────────────────────────────
# Patcher for Tibia's package.json (launcher → wrapper redirect)
# ────────────────────────────────────────────────────────────────
tibiaPatcher = pkgs.writeShellScriptBin "tibia-patch" ''
#!/usr/bin/env bash
set -e
@ -57,7 +63,6 @@ let
exit 0
fi
# Create wrapper inside Tibia package directory
cat > "$LOCALWRAPPER" <<EOF
#!/usr/bin/env bash
${exportLibs}
@ -65,13 +70,14 @@ exec /run/current-system/sw/bin/tibia-client "\$@"
EOF
chmod +x "$LOCALWRAPPER"
# Patch JSON to use the local wrapper
sed -i 's#"executable": "bin/client"#"executable": "tibia-client-wrapper"#' "$PKGJSON"
echo "Tibia client patched to use tibia-client-wrapper."
'';
# Wrapper for the Tibia launcher
# ────────────────────────────────────────────────────────────────
# Wrapper for the Tibia launcher (runs patcher + launcher)
# ────────────────────────────────────────────────────────────────
tibiaLauncherWrapper = pkgs.writeShellScriptBin "tibia" ''
#!/usr/bin/env bash
set -e
@ -90,22 +96,33 @@ EOF
exec steam-run "$LAUNCHER"
'';
# Direct client launcher (bypasses Tibia's launcher entirely)
tibiaDirect = pkgs.writeShellScriptBin "tibia-direct" ''
#!/usr/bin/env bash
CLIENT="$HOME/.local/share/CipSoft GmbH/Tibia/packages/Tibia/bin/client"
if [ ! -x "$CLIENT" ]; then
echo "Tibia client not found."
echo "Run the official launcher once so it downloads the client."
exit 1
fi
${exportLibs}
exec steam-run "$CLIENT"
# ────────────────────────────────────────────────────────────────
# Desktop icon (copied from ~/Gry/Tibia/tibia.ico)
# ────────────────────────────────────────────────────────────────
tibiaIcon = pkgs.runCommand "tibia-icon" {} ''
mkdir -p $out/share/icons/hicolor/256x256/apps
cp "${/home/sasza/Gry/Tibia/tibia.ico}" \
"$out/share/icons/hicolor/256x256/apps/tibia.ico"
'';
# ────────────────────────────────────────────────────────────────
# Desktop entry for Tibia
# ────────────────────────────────────────────────────────────────
tibiaDesktop = pkgs.writeTextFile {
name = "tibia.desktop";
destination = "/share/applications/tibia.desktop";
text = ''
[Desktop Entry]
Type=Application
Name=Tibia
Comment=Launch the Tibia MMORPG
Exec=tibia
Icon=tibia.ico
Terminal=false
Categories=Game;RolePlaying;
'';
};
in
{
environment.systemPackages = [
@ -114,7 +131,8 @@ in
tibiaClientWrapper
tibiaPatcher
tibiaLauncherWrapper
tibiaDirect
tibiaIcon
tibiaDesktop
];
}