1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchurl,
6 bzip2,
7 cmake,
8 pkg-config,
9 gettext,
10 libsodium,
11 SDL2,
12 SDL2_image,
13 SDL_audiolib,
14 simpleini,
15 fmt,
16 libpng,
17 libtiff,
18 libwebp,
19 smpq,
20}:
21
22let
23 # TODO: submit a PR upstream to allow system copies of these libraries where possible
24
25 # fork with patches, far behind upstream
26 asio = fetchurl {
27 url = "https://github.com/diasurgical/asio/archive/4bcf552fcea3e1ae555dde2ab33bc9fa6770da4d.tar.gz";
28 sha256 = "sha256-AFBy5OFsAzxZsiI4DirIHh+VjFkdalEhN9OGqhC0Cvc=";
29 };
30
31 # fork with patches, upstream seems to be dead
32 libmpq = fetchurl {
33 url = "https://github.com/diasurgical/libmpq/archive/b78d66c6fee6a501cc9b95d8556a129c68841b05.tar.gz";
34 sha256 = "sha256-NIzZwr6cBn38uKLWzW+Uet5QiOFUPB5dsf3FsS22ruo=";
35 };
36
37 # not "real" package with pkg-config or cmake file, just collection of source files
38 libsmackerdec = fetchurl {
39 url = "https://github.com/diasurgical/libsmackerdec/archive/91e732bb6953489077430572f43fc802bf2c75b2.tar.gz";
40 sha256 = "sha256-5WXjfvGuT4hG2cnCS4YbxW/c4tek7OR95EjgCqkEi4c=";
41 };
42
43 # fork with patches, far behind upstream
44 libzt = fetchFromGitHub {
45 owner = "diasurgical";
46 repo = "libzt";
47 fetchSubmodules = true;
48 rev = "d6c6a069a5041a3e89594c447ced3f15d77618b8";
49 sha256 = "sha256-ttRJLfaGHzhS4jd8db7BNPWROCti3ZxuRouqsL/M5ew=";
50 };
51in
52
53stdenv.mkDerivation (finalAttrs: {
54 pname = "devilutionx";
55 version = "1.5.4";
56
57 src = fetchFromGitHub {
58 owner = "diasurgical";
59 repo = "devilutionX";
60 tag = finalAttrs.version;
61 hash = "sha256-F23MTe7vMOgIBH6qm7X1+8gIMmN9E+d/GZnFsQZt2cM=";
62 };
63
64 patches = [ ./add-nix-share-path-to-mpq-search.patch ];
65
66 postPatch = ''
67 substituteInPlace 3rdParty/asio/CMakeLists.txt --replace-fail "${asio.url}" "${asio}"
68 substituteInPlace 3rdParty/libmpq/CMakeLists.txt --replace-fail "${libmpq.url}" "${libmpq}"
69 substituteInPlace 3rdParty/libsmackerdec/CMakeLists.txt --replace-fail "${libsmackerdec.url}" "${libsmackerdec}"
70 substituteInPlace 3rdParty/libzt/CMakeLists.txt \
71 --replace-fail "GIT_REPOSITORY https://github.com/diasurgical/libzt.git" "" \
72 --replace-fail "GIT_TAG ${libzt.rev}" "SOURCE_DIR ${libzt}"
73 substituteInPlace Source/init.cpp \
74 --replace-fail "@assets@" "$out/share/diasurgical/devilutionx/"
75 '';
76
77 nativeBuildInputs = [
78 cmake
79 pkg-config
80 gettext
81 smpq # used to build devilutionx.mpq
82 ];
83
84 buildInputs = [
85 bzip2
86 fmt
87 libpng
88 libtiff
89 libwebp
90 libsodium
91 SDL2
92 SDL2_image
93 SDL_audiolib
94 simpleini
95 ];
96
97 meta = {
98 homepage = "https://github.com/diasurgical/devilutionX";
99 description = "Diablo build for modern operating systems";
100 mainProgram = "devilutionx";
101 longDescription = "In order to play this game a copy of diabdat.mpq is required. Place a copy of diabdat.mpq in ~/.local/share/diasurgical/devilution before executing the game.";
102 license = lib.licenses.sustainableUse;
103 maintainers = with lib.maintainers; [
104 aanderse
105 ];
106 platforms = with lib.platforms; linux ++ windows;
107 };
108})