summary refs log tree commit diff
path: root/pkgs/games/andyetitmoves/default.nix
blob: 943f9eb881c52b63fefc85076d9ca30da504387a (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
{ stdenv, fetchurl, libvorbis, libogg, libtheora, SDL, libXft, SDL_image, zlib, libX11, libpng, openal, runtimeShell, requireFile, commercialVersion ? false }:

let plainName = "andyetitmoves";
    version   = "1.2.2";
in

stdenv.mkDerivation {
  name = "${plainName}-${version}";

  src = if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux"
    then
      let postfix        = if stdenv.hostPlatform.system == "i686-linux" then "i386" else "x86_64";
          commercialName = "${plainName}-${version}_${postfix}.tar.gz";
          demoUrl        = "http://www.andyetitmoves.net/demo/${plainName}Demo-${version}_${postfix}.tar.gz";
      in
      if commercialVersion
        then requireFile {
               message = ''
                 We cannot download the commercial 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/${commercialName}" in the
                 directory where yousaved it.
               '';
               name = commercialName;
               sha256 = if stdenv.hostPlatform.system == "i686-linux"
                          then "15wvzmmidvykwjrbnq70h5jrvnjx1hcrm0357qj85q4aqbzavh01"
                          else "1v8z16qa9ka8sf7qq45knsxj87s6sipvv3a7xq11pb5xk08fb2ql";
             }
        else fetchurl {
               url = demoUrl;
               sha256 = if stdenv.hostPlatform.system == "i686-linux"
                          then "0f14vrrbq05hsbdajrb5y9za65fpng1lc8f0adb4aaz27x7sh525"
                          else "0mg41ya0b27blq3b5498kwl4rj46dj21rcd7qd0rw1kyvr7sx4v4";
             }
    else
      throw "And Yet It Moves nix package only supports linux and intel cpu's.";

  phases = "unpackPhase installPhase";

  installPhase = ''
    mkdir -p $out/{opt/andyetitmoves,bin}
    cp -r * $out/opt/andyetitmoves/

    fullPath=${stdenv.cc.cc.lib}/lib64
    for i in $nativeBuildInputs; do
      fullPath=$fullPath''${fullPath:+:}$i/lib
    done

    binName=${if commercialVersion then "AndYetItMoves" else "AndYetItMovesDemo"}

    patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) --set-rpath $fullPath $out/opt/andyetitmoves/lib/$binName
    cat > $out/bin/$binName << EOF
    #!${runtimeShell}
    cd $out/opt/andyetitmoves
    exec ./lib/$binName
    EOF
    chmod +x $out/bin/$binName
  '';

  buildInputs = [libvorbis libogg libtheora SDL libXft SDL_image zlib libX11 libpng openal];

  meta = {
    description = "Physics/Gravity Platform game";

    longDescription = ''
      And Yet It Moves is an award-winning physics-based platform game in which players rotate the game world at will to solve challenging puzzles. Tilting the world turns walls into floors, slides into platforms, and stacks of rocks into dangerous hazards.
    '';

    homepage = http://www.andyetitmoves.net/;

    license = stdenv.lib.licenses.unfree;

    maintainers = with stdenv.lib.maintainers; [bluescreen303];
  };
}