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