138 lines
5.7 KiB
Nix
138 lines
5.7 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
# ────────────────────────────────────────────────────────────────
|
|
# Legacy libxml2 (2.9.x) — Tibia requires libxml2.so.2
|
|
# ────────────────────────────────────────────────────────────────
|
|
libxml2_2_9 = pkgs.stdenv.mkDerivation {
|
|
pname = "libxml2-2.9";
|
|
version = "2.9.14";
|
|
|
|
src = pkgs.fetchurl {
|
|
url = "https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.14.tar.xz";
|
|
sha256 = "sha256-YNdKJX0czsBHXnScui8hVZ5IE577pv8oIkNXx8eY3+4=";
|
|
};
|
|
|
|
nativeBuildInputs = [ pkgs.pkg-config ];
|
|
buildInputs = [ pkgs.zlib pkgs.xz ];
|
|
|
|
configureFlags = [
|
|
"--disable-static"
|
|
"--without-python"
|
|
];
|
|
|
|
enableParallelBuilding = true;
|
|
};
|
|
|
|
# ────────────────────────────────────────────────────────────────
|
|
# Centralized runtime library path for Tibia
|
|
# ────────────────────────────────────────────────────────────────
|
|
tibiaLibPath = lib.makeLibraryPath [
|
|
pkgs.nss
|
|
pkgs.nspr
|
|
pkgs.libxkbfile
|
|
libxml2_2_9
|
|
];
|
|
|
|
exportLibs = ''
|
|
export LD_LIBRARY_PATH="${tibiaLibPath}:$LD_LIBRARY_PATH"
|
|
'';
|
|
|
|
# ────────────────────────────────────────────────────────────────
|
|
# 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 (launcher → wrapper redirect)
|
|
# ────────────────────────────────────────────────────────────────
|
|
tibiaPatcher = pkgs.writeShellScriptBin "tibia-patch" ''
|
|
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
PKGDIR="$HOME/.local/share/CipSoft GmbH/Tibia/packages/Tibia"
|
|
PKGJSON="$PKGDIR/package.json"
|
|
LOCALWRAPPER="$PKGDIR/tibia-client-wrapper"
|
|
|
|
if [ ! -f "$PKGJSON" ]; then
|
|
echo "package.json not found — run the launcher once first."
|
|
exit 0
|
|
fi
|
|
|
|
cat > "$LOCALWRAPPER" <<EOF
|
|
#!/usr/bin/env bash
|
|
${exportLibs}
|
|
exec /run/current-system/sw/bin/tibia-client "\$@"
|
|
EOF
|
|
chmod +x "$LOCALWRAPPER"
|
|
|
|
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 (runs patcher + launcher)
|
|
# ────────────────────────────────────────────────────────────────
|
|
tibiaLauncherWrapper = pkgs.writeShellScriptBin "tibia" ''
|
|
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
LAUNCHER="$HOME/Gry/Tibia/Tibia"
|
|
|
|
if [ ! -x "$LAUNCHER" ]; then
|
|
echo "Tibia launcher not found at:"
|
|
echo " $LAUNCHER"
|
|
exit 1
|
|
fi
|
|
|
|
tibia-patch
|
|
|
|
${exportLibs}
|
|
exec steam-run "$LAUNCHER"
|
|
'';
|
|
|
|
# ────────────────────────────────────────────────────────────────
|
|
# 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 = [
|
|
pkgs.steam-run
|
|
libxml2_2_9
|
|
tibiaClientWrapper
|
|
tibiaPatcher
|
|
tibiaLauncherWrapper
|
|
tibiaIcon
|
|
tibiaDesktop
|
|
];
|
|
}
|
|
|