tibia WORKS!

This commit is contained in:
Sasza Stanczew 2026-02-16 12:58:59 +01:00
parent b946426896
commit 2ac7a5de52

View file

@ -1,14 +1,105 @@
{ pkgs, ... }: {
nixpkgs.overlays = [
(self: super: {
tibia = super.tibia.overrideAttrs (old: {
src = builtins.path { path = "/home/sasza/Gry/tibia.x64.tar.gz"; name = "tibia.tar.gz"; };
});
})
];
# paczki
environment.systemPackages = with pkgs; [
tibia
{ config, pkgs, lib, ... }:
let
# Inline legacy libxml2 (2.9.x) because modern Nixpkgs removed it
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;
};
# Wrapper for the real client
tibiaClientWrapper = pkgs.writeShellScriptBin "tibia-client" ''
#!/usr/bin/env bash
export LD_LIBRARY_PATH="${pkgs.nss}/lib:${pkgs.libxkbfile}/lib:${pkgs.nspr}/lib:${libxml2_2_9}/lib:$LD_LIBRARY_PATH"
exec steam-run "$HOME/.local/share/CipSoft GmbH/Tibia/packages/Tibia/bin/client" "$@"
'';
# Script that patches Tibia's package.json
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
# Create wrapper INSIDE the Tibia package directory
cat > "$LOCALWRAPPER" <<EOF
#!/usr/bin/env bash
export LD_LIBRARY_PATH="${pkgs.nss}/lib:${pkgs.libxkbfile}/lib:${pkgs.nspr}/lib:${libxml2_2_9}/lib:\$LD_LIBRARY_PATH"
exec /run/current-system/sw/bin/tibia-client "\$@"
EOF
chmod +x "$LOCALWRAPPER"
# Patch JSON to use the local wrapper (relative path!)
sed -i 's#"executable": "bin/client"#"executable": "tibia-client-wrapper"#' "$PKGJSON"
echo "Tibia client patched to use tibia-client-wrapper."
'';
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
export LD_LIBRARY_PATH="${pkgs.nss}/lib:${pkgs.libxkbfile}/lib:${pkgs.nspr}/lib:${libxml2_2_9}/lib:$LD_LIBRARY_PATH"
exec steam-run "$LAUNCHER"
'';
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
export LD_LIBRARY_PATH="${pkgs.nss}/lib:${pkgs.libxkbfile}/lib:${pkgs.nspr}/lib:${libxml2_2_9}/lib:$LD_LIBRARY_PATH"
exec steam-run "$CLIENT"
'';
in
{
environment.systemPackages = [
pkgs.steam-run
libxml2_2_9
tibiaClientWrapper
tibiaPatcher
tibiaLauncherWrapper
tibiaDirect
];
}