summary refs log tree commit diff
path: root/pkgs/games/worldofgoo/default.nix
blob: 0889e52d8f86c671c28fe49cc4326ee858ab3c23 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ stdenv, requireFile
, libX11, libXext, libXau, libxcb, libXdmcp , SDL, SDL_mixer, libvorbis, libGLU, libGL
, runtimeShell
, demo ? false }:

# TODO: add i686 support

stdenv.mkDerivation rec {
  name = if demo
    then "WorldOfGooDemo-1.41"
    else "WorldofGoo-1.41";

  arch = if stdenv.hostPlatform.system == "x86_64-linux" then "supported"
    else throw "Sorry. World of Goo only is only supported on x86_64 now.";

  goBuyItNow = ''
    We cannot download the full version automatically, as you require a license.
    Once you bought a license, you need to add your downloaded version to the nix store.
    You can do this by using "nix-prefetch-url file://\$PWD/WorldOfGooSetup.1.41.tar.gz" in the
    directory where you saved it.

    Or you can install the demo version: 'nix-env -i -A pkgs.worldofgoo_demo'.
  '';

  getTheDemo = ''
    We cannot download the demo version automatically. Please go to
    http://worldofgoo.com/dl2.php?lk=demo, then add it to your nix store.
    You can do this by using "nix-prefetch-url file://\$PWD/WorldOfGooDemo.1.41.tar.gz" in the
    directory where you saved it.
  '';

  src = if demo
    then
      requireFile {
         message = getTheDemo;
         name = "WorldOfGooDemo.1.41.tar.gz";
         sha256 = "0ndcix1ckvcj47sgndncr3hxjcg402cbd8r16rhq4cc43ibbaxri";
       }
    else
      requireFile {
        message = goBuyItNow;
        name = "WorldOfGooSetup.1.41.tar.gz";
        sha256 = "0rj5asx4a2x41ncwdby26762my1lk1gaqar2rl8dijfnpq8qlnk7";
      };

  phases = "unpackPhase installPhase";

  # XXX: stdenv.lib.makeLibraryPath doesn't pick up /lib64
  libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.cc stdenv.cc.libc ]
    + ":" + stdenv.lib.makeLibraryPath [libX11 libXext libXau libxcb libXdmcp SDL SDL_mixer libvorbis libGLU libGL ]
    + ":" + stdenv.cc.cc + "/lib64";

  installPhase = ''
    mkdir -p $out/libexec/2dboy/WorldOfGoo/
    mkdir -p $out/bin

    patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath $libPath ./WorldOfGoo.bin64

    cp -r * $out/libexec/2dboy/WorldOfGoo/

    #makeWrapper doesn't do cd. :(

    cat > $out/bin/WorldofGoo << EOF
    #!${runtimeShell}
    cd $out/libexec/2dboy/WorldOfGoo
    exec ./WorldOfGoo.bin64
    EOF
    chmod +x $out/bin/WorldofGoo
  '';

  meta = with stdenv.lib; {
    description = "A physics based puzzle game";
    longDescription = ''
      World of Goo is a physics based puzzle / construction game. The millions of Goo
      Balls who live in the beautiful World of Goo don't know that they are in a
      game, or that they are extremely delicious.
    '';
    homepage = http://worldofgoo.com;
    license = licenses.unfree;
    maintainers = with maintainers; [ jcumming ];
  };

}