summary refs log tree commit diff
path: root/pkgs/games/rott/default.nix
blob: cac357faf2e04ec9e1f0e5e17ce26618a882f443 (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
{stdenv, lib, fetchurl, SDL, SDL_mixer, makeDesktopItem, copyDesktopItems, runtimeShell, buildShareware ? false}:

stdenv.mkDerivation rec {
  pname = "rott";
  version = "1.1.2";

  src = fetchurl {
    url = "https://icculus.org/rott/releases/${pname}-${version}.tar.gz";
    sha256 = "1zr7v5dv2iqx40gzxbg8mhac7fxz3kqf28y6ysxv1xhjqgl1c98h";
  };

  nativeBuildInputs = [ copyDesktopItems ];
  buildInputs = [ SDL SDL_mixer ];

  preBuild = ''
    cd rott
    make clean
    make SHAREWARE=${if buildShareware then "1" else "0"}
  '';

  # Include a wrapper script to allow the game to be launched from a user's PATH and load the game data from the user's home directory.

  installPhase = ''
    mkdir -p $out/bin
    cp rott $out/bin

    cat > $out/bin/launch-rott <<EOF
    #! ${runtimeShell} -e
    cd ~/.rott/data
    exec $out/bin/rott
    EOF

    chmod +x $out/bin/launch-rott

    runHook postInstall
  '';

  desktopItems = [
    (makeDesktopItem {
      name = "rott";
      exec = "launch-rott";
      desktopName = "Rise of the Triad: ${if buildShareware then "The HUNT Begins" else "Dark War"}";
      categories = "Game;";
    })
  ];

  meta = with lib; {
    description = "SDL port of Rise of the Triad";
    homepage = "https://icculus.org/rott/";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ sander ];
    platforms = platforms.all;
  };
}