1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchurl,
6 SDL2,
7 cmake,
8 libpng,
9 libzip,
10 openal,
11 pkg-config,
12 yaml-cpp,
13 fmt,
14 xorg,
15}:
16let
17 sfl-src = fetchFromGitHub {
18 owner = "slavenf";
19 repo = "sfl-library";
20 tag = "1.9.0";
21 hash = "sha256-Udry/Y753l274PU6RvpPgkIr85wSCnz3mLQ0xzerUAc=";
22 };
23
24 openloco-objects = fetchurl {
25 url = "https://github.com/OpenLoco/OpenGraphics/releases/download/v0.1.1/objects.zip";
26 sha256 = "e75ad13a8e8d58458e0c54e5ce62902a073d7bb025ef8fb97cb56108ff7c57c3";
27 };
28
29in
30stdenv.mkDerivation rec {
31 pname = "openloco";
32 version = "25.02";
33
34 src = fetchFromGitHub {
35 owner = "OpenLoco";
36 repo = "OpenLoco";
37 tag = "v${version}";
38 hash = "sha256-RsiEYBNx+Lf7OyyyCShQmgtwBuxDrZkRCYCbMmZ8ZMM=";
39 };
40
41 postPatch = ''
42 # the upstream build process determines the version tag from git; since we
43 # are not using a git checkout, we patch it manually
44 sed -i '/#define NAME "OpenLoco"/a#define OPENLOCO_VERSION_TAG "${version}"' src/OpenLoco/src/Version.cpp
45
46 # prefetch sfl header sources
47 grep -q 'GIT_TAG \+${sfl-src.tag}' thirdparty/CMakeLists.txt
48 sed -i 's#GIT_REPOSITORY \+https://github.com/slavenf/sfl-library#SOURCE_DIR ${sfl-src}#' thirdparty/CMakeLists.txt
49
50 # prefetch openloco-objects
51 sed -i 's#URL \+${openloco-objects.url}#URL ${openloco-objects}#' CMakeLists.txt
52 '';
53
54 NIX_CFLAGS_COMPILE = "-Wno-error=null-dereference";
55
56 cmakeFlags = [
57 "-DOPENLOCO_BUILD_TESTS=NO"
58 ];
59
60 nativeBuildInputs = [
61 cmake
62 pkg-config
63 ];
64
65 buildInputs = [
66 SDL2
67 libpng
68 libzip
69 openal
70 yaml-cpp
71 fmt
72 xorg.libX11
73 ];
74
75 meta = {
76 description = "Open source re-implementation of Chris Sawyer's Locomotion";
77 homepage = "https://github.com/OpenLoco/OpenLoco";
78 license = lib.licenses.mit;
79 platforms = lib.platforms.linux;
80 maintainers = with lib.maintainers; [ icewind1991 ];
81 };
82}