1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 gitUpdater,
6 cmake,
7 glew,
8 liblockfile,
9 openal,
10 libtheora,
11 SDL2,
12 lzo,
13 libjpeg,
14 libogg,
15 pcre,
16 makeWrapper,
17}:
18
19stdenv.mkDerivation (finalAttrs: {
20 pname = "openxray";
21 version = "2921-january-2025-rc1";
22
23 src = fetchFromGitHub {
24 owner = "OpenXRay";
25 repo = "xray-16";
26 tag = finalAttrs.version;
27 fetchSubmodules = true;
28 hash = "sha256-PYRC1t4gjT2d41ZZOZJF4u3vc0Pq7DpivEnnfbcSQYk=";
29 };
30
31 # Don't force-override these please
32 postPatch = ''
33 substituteInPlace Externals/LuaJIT-proj/CMakeLists.txt \
34 --replace-fail 'set(CMAKE_OSX_SYSROOT' '#set(CMAKE_OSX_SYSROOT' \
35 --replace-fail 'set(ENV{SDKROOT}' '#set(ENV{SDKROOT}'
36 '';
37
38 strictDeps = true;
39
40 nativeBuildInputs = [
41 cmake
42 makeWrapper
43 ];
44
45 buildInputs = [
46 glew
47 liblockfile
48 openal
49 libtheora
50 SDL2
51 lzo
52 libjpeg
53 libogg
54 pcre
55 ];
56
57 cmakeFlags = [
58 # Breaks on Darwin
59 (lib.cmakeBool "USE_LTO" (!stdenv.hostPlatform.isDarwin))
60 ]
61 ++ lib.optionals stdenv.hostPlatform.isDarwin [
62 # This seemingly only gets set properly by CMake when using the XCode generator
63 (lib.cmakeFeature "CMAKE_OSX_DEPLOYMENT_TARGET" "${stdenv.hostPlatform.darwinMinVersion}")
64 ];
65
66 # Crashes can happen, we'd like them to be reasonably debuggable
67 cmakeBuildType = "RelWithDebInfo";
68 dontStrip = true;
69
70 # Because we work around https://github.com/OpenXRay/xray-16/issues/1224 by using GCC,
71 # we need a followup workaround for Darwin locale stuff when using GCC:
72 # runtime error: locale::facet::_S_create_c_locale name not valid
73 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
74 wrapProgram $out/bin/xr_3da \
75 --run 'export LC_ALL=C'
76 '';
77
78 # dlopens its own libraries, relies on rpath not having its prefix stripped
79 dontPatchELF = true;
80
81 passthru.updateScript = gitUpdater { };
82
83 meta = with lib; {
84 mainProgram = "xr_3da";
85 description = "Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World";
86 homepage = "https://github.com/OpenXRay/xray-16/";
87 license = licenses.unfree // {
88 url = "https://github.com/OpenXRay/xray-16/blob/${finalAttrs.version}/License.txt";
89 };
90 maintainers = with maintainers; [ OPNA2608 ];
91 platforms = [
92 "x86_64-linux"
93 "i686-linux"
94 "aarch64-linux"
95 "x86_64-darwin"
96 "aarch64-darwin"
97 ];
98 };
99})