nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5
6 cmake,
7 copyDesktopItems,
8 deutex,
9 makeDesktopItem,
10 makeWrapper,
11 pkg-config,
12 wrapGAppsHook3,
13
14 SDL2,
15 SDL2_mixer,
16 SDL2_net,
17 alsa-lib,
18 cpptrace,
19 curl,
20 expat,
21 fltk,
22 libdwarf,
23 libselinux,
24 libsepol,
25 libsysprof-capture,
26 libuuid,
27 libxdmcp,
28 libxkbcommon,
29 pcre2,
30 portmidi,
31 wayland-scanner,
32 waylandpp,
33 wxGTK32,
34 libx11,
35 xorgproto,
36 zstd,
37
38 nix-update-script,
39
40 withX11 ? stdenv.hostPlatform.isLinux,
41 withWayland ? stdenv.hostPlatform.isLinux,
42}:
43
44let
45 # TODO: remove when this is resolved, likely at the next cpptrace bump
46 cpptrace' = cpptrace.overrideAttrs {
47 # tests are failing on darwin
48 # https://hydra.nixos.org/build/310535948
49 doCheck = !stdenv.hostPlatform.isDarwin;
50 };
51in
52
53stdenv.mkDerivation (finalAttrs: {
54 pname = "odamex";
55 version = "12.1.0";
56
57 src = fetchFromGitHub {
58 owner = "odamex";
59 repo = "odamex";
60 tag = finalAttrs.version;
61 hash = "sha256-kLI1gdGH5NXJ8YI1tR0N5W6yvGZ+7302z0QLl2j+b0k=";
62 fetchSubmodules = true;
63 };
64
65 nativeBuildInputs = [
66 cmake
67 copyDesktopItems
68 deutex
69 makeWrapper
70 pkg-config
71 ]
72 ++ lib.optionals stdenv.hostPlatform.isLinux [
73 wrapGAppsHook3
74 ];
75
76 buildInputs = [
77 SDL2
78 SDL2_mixer
79 SDL2_net
80 cpptrace'
81 curl
82 expat
83 fltk
84 libdwarf
85 libsysprof-capture
86 pcre2
87 portmidi
88 wxGTK32
89 zstd
90 ]
91 ++ lib.optionals stdenv.hostPlatform.isLinux [
92 alsa-lib
93 libselinux
94 libuuid
95 libxdmcp
96 libsepol
97 ]
98 ++ lib.optionals withX11 [
99 libx11
100 xorgproto
101 ]
102 ++ lib.optionals withWayland [
103 libxkbcommon
104 wayland-scanner
105 waylandpp
106 ];
107
108 cmakeFlags = [
109 (lib.cmakeBool "USE_INTERNAL_CPPTRACE" false)
110 (lib.cmakeFeature "ODAMEX_INSTALL_BINDIR" "$ODAMEX_BINDIR") # set by wrapper
111 ];
112
113 installPhase = ''
114 runHook preInstall
115
116 ${
117 if stdenv.hostPlatform.isDarwin then
118 # bash
119 ''
120 mkdir -p $out/{Applications,bin}
121
122 mv client odamex
123 for name in odamex odalaunch; do
124 contents="Applications/$name.app/Contents/MacOS"
125 mv $name/*.app $out/Applications
126 makeWrapper $out/{"$contents",bin}/"$name" \
127 --set ODAMEX_BINDIR "${placeholder "out"}/Applications"
128 done
129
130 cp server/odasrv $out/Applications
131 ln -s $out/Applications/odamex.app/Contents/MacOS/odamex.wad $out/Applications
132 makeWrapper $out/{Applications,bin}/odasrv
133 ''
134 else
135 # bash
136 ''
137 make install
138
139 # copy desktop file icons
140 for name in odamex odalaunch odasrv; do
141 for size in 96 128 256 512; do
142 install -Dm644 ../media/icon_"$name"_"$size".png \
143 $out/share/icons/hicolor/"$size"x"$size"/"$name".png
144 done
145
146 install -Dm644 ../media/icon_"$name"_128.png \
147 $out/share/pixmaps/"$name".png
148 done
149 ''
150 }
151
152 runHook postInstall
153 '';
154
155 preFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
156 gappsWrapperArgs+=(
157 --set ODAMEX_BINDIR "${placeholder "out"}/bin"
158 )
159 '';
160
161 desktopItems = [
162 (makeDesktopItem {
163 name = "odamex";
164 icon = "odamex";
165 exec = "odamex";
166 desktopName = "Odamex Client";
167 comment = "A Doom multiplayer game engine";
168 categories = [
169 "ActionGame"
170 "Game"
171 "Shooter"
172 ];
173 })
174 (makeDesktopItem {
175 name = "odalaunch";
176 icon = "odalaunch";
177 exec = "odalaunch";
178 desktopName = "Odamex Launcher";
179 comment = "Server Browser for Odamex";
180 categories = [
181 "ActionGame"
182 "Game"
183 "Shooter"
184 ];
185 })
186 (makeDesktopItem {
187 name = "odasrv";
188 icon = "odasrv";
189 exec = "odasrv";
190 desktopName = "Odamex Server";
191 comment = "Run an Odamex game server";
192 categories = [
193 "Network"
194 ];
195 })
196 ];
197
198 passthru.updateScript = nix-update-script { };
199
200 meta = {
201 homepage = "https://odamex.net";
202 description = "Client/server port for playing old-school Doom online";
203 changelog = "https://github.com/odamex/odamex/releases/tag/${finalAttrs.src.tag}";
204 license = lib.licenses.gpl2Only;
205 platforms = lib.platforms.unix;
206 broken = stdenv.hostPlatform.isDarwin;
207 maintainers = with lib.maintainers; [ eljamm ];
208 mainProgram = "odalaunch";
209 };
210})