1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 SDL2,
6 SDL2_image,
7 libX11,
8 rtaudio,
9 rtmidi,
10 glew,
11 alsa-lib,
12 angelscript,
13 cmake,
14 pkg-config,
15 zenity,
16 withEditor ? true,
17}:
18stdenv.mkDerivation (finalAttrs: {
19 pname = "theforceengine";
20 version = "1.22.300";
21
22 src = fetchFromGitHub {
23 owner = "luciusDXL";
24 repo = "TheForceEngine";
25 tag = "v${finalAttrs.version}";
26 hash = "sha256-m/VNlcuvpJkcfTpL97gCUTQtdAWqimVrhU0qLj0Erck=";
27 };
28
29 nativeBuildInputs = [
30 cmake
31 pkg-config
32 ];
33
34 buildInputs = [
35 SDL2
36 SDL2_image
37 libX11
38 rtaudio
39 rtmidi
40 glew
41 alsa-lib
42 angelscript
43 zenity
44 ];
45
46 hardeningDisable = [ "format" ];
47
48 cmakeFlags = [
49 (lib.cmakeBool "ENABLE_EDITOR" withEditor)
50 ];
51
52 prePatch = ''
53 # use nix store path instead of hardcoded /usr/share for support data
54 substituteInPlace TheForceEngine/TFE_FileSystem/paths-posix.cpp \
55 --replace-fail "/usr/share" "$out/share"
56
57 # use zenity from nix store
58 substituteInPlace TheForceEngine/TFE_Ui/portable-file-dialogs.h \
59 --replace-fail "check_program(\"zenity\")" "check_program(\"${lib.getExe zenity}\")" \
60 --replace-fail "flags(flag::has_zenity) ? \"zenity\"" "flags(flag::has_zenity) ? \"${lib.getExe zenity}\""
61 '';
62
63 meta = {
64 description = "Modern \"Jedi Engine\" replacement supporting Dark Forces, mods, and in the future, Outlaws";
65 mainProgram = "theforceengine";
66 homepage = "https://theforceengine.github.io";
67 license = lib.licenses.gpl2Only;
68 maintainers = with lib.maintainers; [ devusb ];
69 platforms = lib.platforms.linux;
70 };
71})