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, ... }: { config, pkgs, lib, ... }:
let 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 { libxml2_2_9 = pkgs.stdenv.mkDerivation {
pname = "libxml2-2.9"; pname = "libxml2-2.9";
version = "2.9.14"; version = "2.9.14";
@ -22,28 +24,32 @@ let
enableParallelBuilding = true; enableParallelBuilding = true;
}; };
# ────────────────────────────────────────────────────────────────
# Centralized runtime library path for Tibia # Centralized runtime library path for Tibia
tibiaLibPath = # ────────────────────────────────────────────────────────────────
lib.makeLibraryPath [ tibiaLibPath = lib.makeLibraryPath [
pkgs.nss pkgs.nss
pkgs.nspr pkgs.nspr
pkgs.libxkbfile pkgs.libxkbfile
libxml2_2_9 libxml2_2_9
]; ];
# Helper: LD_LIBRARY_PATH export line
exportLibs = '' exportLibs = ''
export LD_LIBRARY_PATH="${tibiaLibPath}:$LD_LIBRARY_PATH" 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" '' tibiaClientWrapper = pkgs.writeShellScriptBin "tibia-client" ''
#!/usr/bin/env bash #!/usr/bin/env bash
${exportLibs} ${exportLibs}
exec steam-run "$HOME/.local/share/CipSoft GmbH/Tibia/packages/Tibia/bin/client" "$@" 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" '' tibiaPatcher = pkgs.writeShellScriptBin "tibia-patch" ''
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
@ -57,7 +63,6 @@ let
exit 0 exit 0
fi fi
# Create wrapper inside Tibia package directory
cat > "$LOCALWRAPPER" <<EOF cat > "$LOCALWRAPPER" <<EOF
#!/usr/bin/env bash #!/usr/bin/env bash
${exportLibs} ${exportLibs}
@ -65,13 +70,14 @@ exec /run/current-system/sw/bin/tibia-client "\$@"
EOF EOF
chmod +x "$LOCALWRAPPER" chmod +x "$LOCALWRAPPER"
# Patch JSON to use the local wrapper
sed -i 's#"executable": "bin/client"#"executable": "tibia-client-wrapper"#' "$PKGJSON" sed -i 's#"executable": "bin/client"#"executable": "tibia-client-wrapper"#' "$PKGJSON"
echo "Tibia client patched to use tibia-client-wrapper." 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" '' tibiaLauncherWrapper = pkgs.writeShellScriptBin "tibia" ''
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
@ -90,22 +96,33 @@ EOF
exec steam-run "$LAUNCHER" exec steam-run "$LAUNCHER"
''; '';
# Direct client launcher (bypasses Tibia's launcher entirely) # ────────────────────────────────────────────────────────────────
tibiaDirect = pkgs.writeShellScriptBin "tibia-direct" '' # Desktop icon (copied from ~/Gry/Tibia/tibia.ico)
#!/usr/bin/env bash # ────────────────────────────────────────────────────────────────
tibiaIcon = pkgs.runCommand "tibia-icon" {} ''
CLIENT="$HOME/.local/share/CipSoft GmbH/Tibia/packages/Tibia/bin/client" mkdir -p $out/share/icons/hicolor/256x256/apps
cp "${/home/sasza/Gry/Tibia/tibia.ico}" \
if [ ! -x "$CLIENT" ]; then "$out/share/icons/hicolor/256x256/apps/tibia.ico"
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 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 in
{ {
environment.systemPackages = [ environment.systemPackages = [
@ -114,7 +131,8 @@ in
tibiaClientWrapper tibiaClientWrapper
tibiaPatcher tibiaPatcher
tibiaLauncherWrapper tibiaLauncherWrapper
tibiaDirect tibiaIcon
tibiaDesktop
]; ];
} }