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