1{
2 lib,
3 stdenv,
4 requireFile,
5 SDL,
6 libpulseaudio,
7 alsa-lib,
8 runtimeShell,
9}:
10
11stdenv.mkDerivation rec {
12 pname = "vessel";
13 version = "12082012";
14
15 goBuyItNow = ''
16 We cannot download the full version automatically, as you require a license.
17 Once you bought a license, you need to add your downloaded version to the nix store.
18 You can do this by using "nix-prefetch-url file://\$PWD/vessel-${version}-bin" in the
19 directory where you saved it.
20 '';
21
22 src =
23 if (stdenv.hostPlatform.isi686) then
24 requireFile {
25 message = goBuyItNow;
26 name = "vessel-${version}-bin";
27 sha256 = "1vpwcrjiln2mx43h7ib3jnccyr3chk7a5x2bw9kb4lw8ycygvg96";
28 }
29 else
30 throw "unsupported platform ${stdenv.hostPlatform.system} only i686-linux supported for now.";
31
32 phases = "installPhase";
33 ld_preload = ./isatty.c;
34
35 libPath =
36 lib.makeLibraryPath [
37 stdenv.cc.cc
38 stdenv.cc.libc
39 ]
40 + ":"
41 + lib.makeLibraryPath [
42 SDL
43 libpulseaudio
44 alsa-lib
45 ];
46
47 installPhase = ''
48 mkdir -p $out/libexec/strangeloop/vessel/
49 mkdir -p $out/bin
50
51 # allow scripting of the mojoinstaller
52 gcc -fPIC -shared -o isatty.so $ld_preload
53
54 echo @@@
55 echo @@@ this next step appears to hang for a while
56 echo @@@
57
58 # if we call ld.so $(bin) we don't need to set the ELF interpreter, and save a patchelf step.
59 LD_PRELOAD=./isatty.so $(cat $NIX_CC/nix-support/dynamic-linker) $src << IM_A_BOT
60 n
61 $out/libexec/strangeloop/vessel/
62 IM_A_BOT
63
64 # use nix SDL libraries
65 rm $out/libexec/strangeloop/vessel/x86/libSDL*
66 rm $out/libexec/strangeloop/vessel/x86/libstdc++*
67
68 # props to Ethan Lee (the Vessel porter) for understanding
69 # how $ORIGIN works in rpath. There is hope for humanity.
70 patchelf \
71 --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
72 --set-rpath $libPath:$out/libexec/strangeloop/vessel/x86/ \
73 $out/libexec/strangeloop/vessel/x86/vessel.x86
74
75 # we need to libs to find their deps
76 for lib in $out/libexec/strangeloop/vessel/x86/lib* ; do
77 patchelf \
78 --set-rpath $libPath:$out/libexec/strangeloop/vessel/x86/ \
79 $lib
80 done
81
82 cat > $out/bin/Vessel << EOW
83 #!${runtimeShell}
84 cd $out/libexec/strangeloop/vessel/
85 exec ./x86/vessel.x86
86 EOW
87
88 chmod +x $out/bin/Vessel
89 '';
90
91 meta = with lib; {
92 description = "Fluid physics based puzzle game";
93 longDescription = ''
94 Living liquid machines have overrun this world of unstoppable progress,
95 and it is the role of their inventor, Arkwright, to stop the chaos they are
96 causing. Vessel is a game about a man with the power to bring ordinary matter
97 to life, and all the consequences that ensue.
98 '';
99 homepage = "http://www.strangeloopgames.com";
100 license = licenses.unfree;
101 maintainers = with maintainers; [ jcumming ];
102 };
103
104}