nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 config,
4 fetchzip,
5 stdenv,
6 SDL,
7 SDL_image,
8 SDL_ttf,
9 SDL_mixer,
10 libmysqlclient,
11 wxGTK32,
12 symlinkJoin,
13 runCommandLocal,
14 makeWrapper,
15 coreutils,
16 scalingFactor ? 2, # this is to resize the fixed-size zod_launcher window
17 replaceVars,
18}:
19let
20 pname = "zod-engine";
21 version = "2011-09-06";
22 src = fetchzip {
23 url = "mirror://sourceforge/zod/linux_releases/zod_linux-${version}.tar.gz";
24 sha256 = "017v96aflrv07g8j8zk9mq8f8rqxl5228rjff5blq8dxpsv1sx7h";
25 };
26 postPatch = ''
27 sed '1i#include <ctime>' -i zod_src/common.cpp # gcc12
28 '';
29 nativeBuildInputs = [
30 makeWrapper
31 ];
32 buildInputs = [
33 SDL
34 SDL_image
35 SDL_ttf
36 SDL_mixer
37 libmysqlclient
38 wxGTK32
39 coreutils
40 ];
41 hardeningDisable = [ "format" ];
42 NIX_LDFLAGS = "-L${libmysqlclient}/lib/mysql";
43 zod_engine = stdenv.mkDerivation {
44 inherit
45 version
46 src
47 postPatch
48 nativeBuildInputs
49 buildInputs
50 hardeningDisable
51 NIX_LDFLAGS
52 ;
53 pname = "${pname}-engine";
54 enableParallelBuilding = true;
55 preBuild = "cd zod_src";
56 installPhase = ''
57 mkdir -p $out/bin
58 install -m755 zod $out/bin/
59 wrapProgram $out/bin/zod --chdir "${zod_assets}/usr/lib/commander-zod"
60 '';
61 };
62 zod_map_editor = stdenv.mkDerivation {
63 inherit
64 version
65 src
66 postPatch
67 nativeBuildInputs
68 buildInputs
69 hardeningDisable
70 NIX_LDFLAGS
71 ;
72 pname = "${pname}-map_editor";
73 enableParallelBuilding = true;
74 preBuild = "cd zod_src";
75 makeFlags = [ "map_editor" ];
76 installPhase = ''
77 mkdir -p $out/bin
78 install -m755 zod_map_editor $out/bin
79 wrapProgram $out/bin/zod_map_editor --chdir "${zod_assets}/usr/lib/commander-zod"
80 '';
81 };
82 zod_launcher = stdenv.mkDerivation {
83 inherit
84 version
85 src
86 nativeBuildInputs
87 buildInputs
88 zod_engine
89 zod_map_editor
90 ;
91 pname = "${pname}-launcher";
92 # This is necessary because the zod_launcher has terrible fixed-width window
93 # the Idea is to apply the scalingFactor to all positions and sizes and I tested 1,2,3 and 4
94 # 2,3,4 look acceptable on my 4k monitor and 1 is unreadable.
95 # also the ./ in the run command is removed to have easier time starting the game
96 patches = [
97 (replaceVars ./0002-add-scaling-factor-to-source.patch {
98 inherit scalingFactor;
99 })
100 ];
101 postPatch = ''
102 substituteInPlace zod_launcher_src/zod_launcherFrm.cpp \
103 --replace 'message = wxT("./zod");' 'message = wxT("zod");' \
104 --replace "check.replace(i,1,1,'_');" "check.replace(i,1,1,(wxUniChar)'_');"
105 '';
106 preBuild = "cd zod_launcher_src";
107 installPhase = ''
108 mkdir -p $out/bin
109 install -m755 zod_launcher $out/bin
110 '';
111 };
112 zod_assets = runCommandLocal "${pname}-assets" { } ''
113 mkdir -p $out/usr/lib/commander-zod{,blank_maps}
114 cp -r ${src}/assets $out/usr/lib/commander-zod/assets
115 for i in ${src}/*.map ${src}/*.txt; do
116 install -m644 $i $out/usr/lib/commander-zod
117 done
118 for map in ${src}/blank_maps/*; do
119 install -m644 $map $out/usr/lib/commander-zod/blank_maps
120 done
121 '';
122in
123symlinkJoin {
124 inherit pname version;
125 paths = [
126 zod_engine
127 zod_launcher
128 zod_map_editor
129 zod_assets
130 ];
131 meta = with lib; {
132 description = "Multiplayer remake of ZED";
133 homepage = "https://zod.sourceforge.net/";
134 maintainers = with maintainers; [ zeri ];
135 license = licenses.gpl3Plus; # Says the website
136 platforms = platforms.linux;
137 };
138}