lol
1{
2 lib,
3 stdenv,
4 fetchurl,
5 makeDesktopItem,
6 makeWrapper,
7 premake4,
8 unzip,
9 openal,
10 libpng,
11 libvorbis,
12 libGLU,
13 SDL2,
14 SDL2_image,
15 SDL2_ttf,
16}:
17
18stdenv.mkDerivation rec {
19 pname = "tome4";
20 version = "1.7.6";
21
22 src = fetchurl {
23 url = "https://te4.org/dl/t-engine/t-engine4-src-${version}.tar.bz2";
24 sha256 = "sha256-mJ3qAIA/jNyt4CT0ZH1IC7GsDUN8JUKSwHVJwnKkaAw=";
25 };
26
27 desktop = makeDesktopItem {
28 desktopName = pname;
29 name = pname;
30 exec = "@out@/bin/${pname}";
31 icon = pname;
32 comment = "An open-source, single-player, role-playing roguelike game set in the world of Eyal.";
33 type = "Application";
34 categories = [
35 "Game"
36 "RolePlaying"
37 ];
38 genericName = pname;
39 };
40
41 prePatch = ''
42 # http://forums.te4.org/viewtopic.php?f=42&t=49478&view=next#p234354
43 sed -i 's|#include <GL/glext.h>||' src/tgl.h
44 '';
45
46 nativeBuildInputs = [
47 makeWrapper
48 unzip
49 premake4
50 ];
51
52 # tome4 vendors quite a few libraries so someone might want to look
53 # into avoiding that...
54 buildInputs = [
55 libGLU
56 openal
57 libpng
58 libvorbis
59 SDL2
60 SDL2_ttf
61 SDL2_image
62 ];
63
64 # disable parallel building as it caused sporadic build failures
65 enableParallelBuilding = false;
66
67 env.NIX_CFLAGS_COMPILE = "-I${lib.getInclude SDL2}/include/SDL2 -I${SDL2_image}/include/SDL2 -I${SDL2_ttf}/include/SDL2";
68
69 makeFlags = [ "config=release" ];
70
71 # The wrapper needs to cd into the correct directory as tome4's detection of
72 # the game asset root directory is faulty.
73
74 installPhase = ''
75 runHook preInstall
76
77 dir=$out/share/${pname}
78
79 install -Dm755 t-engine $dir/t-engine
80 cp -r bootstrap game $dir
81 makeWrapper $dir/t-engine $out/bin/${pname} \
82 --chdir "$dir"
83
84 install -Dm755 ${desktop}/share/applications/${pname}.desktop $out/share/applications/${pname}.desktop
85 substituteInPlace $out/share/applications/${pname}.desktop \
86 --subst-var out
87
88 unzip -oj -qq game/engines/te4-${version}.teae data/gfx/te4-icon.png
89 install -Dm644 te4-icon.png $out/share/icons/hicolor/64x64/${pname}.png
90
91 install -Dm644 -t $out/share/doc/${pname} CONTRIBUTING COPYING COPYING-MEDIA CREDITS
92
93 runHook postInstall
94 '';
95
96 meta = with lib; {
97 description = "Tales of Maj'eyal (rogue-like game)";
98 mainProgram = "tome4";
99 homepage = "https://te4.org/";
100 license = licenses.gpl3;
101 maintainers = with maintainers; [ peterhoeg ];
102 platforms = [
103 "i686-linux"
104 "x86_64-linux"
105 ];
106 };
107}