at 24.05-pre 57 lines 1.9 kB view raw
1{ lib, stdenv, fetchurl, glibc, libX11, runtimeShell, libGLU, libGL }: 2 3stdenv.mkDerivation rec { 4 pname = "tibia"; 5 version = "10.90"; 6 7 src = fetchurl { 8 url = "http://static.tibia.com/download/tibia${lib.replaceStrings ["."] [""] version}.tgz"; 9 sha256 = "11mkh2dynmbpay51yfaxm5dmcys3rnpk579s9ypfkhblsrchbkhx"; 10 }; 11 12 shell = stdenv.shell; 13 14 # These binaries come stripped already and trying to strip after the 15 # files are in $out/res and after patchelf just breaks them. 16 # Strangely it works if the files are in $out but then nix doesn't 17 # put them in our PATH. We set all the files to $out/res because 18 # we'll be using a wrapper to start the program which will go into 19 # $out/bin. 20 dontStrip = true; 21 22 installPhase = '' 23 mkdir -pv $out/res 24 cp -r * $out/res 25 26 patchelf --set-interpreter ${glibc.out}/lib/ld-linux.so.2 \ 27 --set-rpath ${lib.makeLibraryPath [ stdenv.cc.cc libX11 libGLU libGL ]} \ 28 "$out/res/Tibia" 29 30 # We've patchelf'd the files. The main Tibia binary is a bit 31 # dumb so it looks for ./Tibia.dat. This requires us to be in 32 # the same directory as the file itself but that's very tedious, 33 # especially with nix which changes store hashes. Here we generate 34 # a simple wrapper that we put in $out/bin which will do the 35 # directory changing for us. 36 37 mkdir -pv $out/bin 38 39 # The wrapper script itself. We use $LD_LIBRARY_PATH for libGL. 40 cat << EOF > "$out/bin/Tibia" 41 #!${runtimeShell} 42 cd $out/res 43 ${glibc.out}/lib/ld-linux.so.2 --library-path \$LD_LIBRARY_PATH ./Tibia "\$@" 44 EOF 45 46 chmod +x $out/bin/Tibia 47 48 ''; 49 50 meta = { 51 description = "Top-down MMORPG set in a fantasy world"; 52 homepage = "http://tibia.com"; 53 license = lib.licenses.unfree; 54 platforms = ["i686-linux"]; 55 maintainers = with lib.maintainers; [ ]; 56 }; 57}