1{ stdenv, fetchurl, flac, gtk2, libvorbis, libvpx, makeDesktopItem, libGLU_combined, nasm
2, pkgconfig, SDL2, SDL2_mixer }:
3
4let
5 year = "2015";
6 date = "20150420";
7 rev = "5160";
8in stdenv.mkDerivation rec {
9 name = "eduke32-${version}";
10 version = "${date}-${rev}";
11
12 src = fetchurl {
13 url = "http://dukeworld.duke4.net/eduke32/synthesis/old/${year}/${version}/eduke32_src_${version}.tar.xz";
14 sha256 = "1nlq5jbglg00c1z1vsyl627fh0mqfxvk5qyxav5vzla2b4svik2v";
15 };
16
17 buildInputs = [ flac gtk2 libvorbis libvpx libGLU_combined SDL2 SDL2_mixer ]
18 ++ stdenv.lib.optional (stdenv.hostPlatform.system == "i686-linux") nasm;
19 nativeBuildInputs = [ pkgconfig ];
20
21 postPatch = ''
22 substituteInPlace build/src/glbuild.c \
23 --replace libGL.so ${libGLU_combined}/lib/libGL.so \
24 --replace libGLU.so ${libGLU_combined}/lib/libGLU.so
25 '';
26
27 NIX_CFLAGS_COMPILE = "-I${SDL2.dev}/include/SDL2 -I${SDL2_mixer}/include/SDL2";
28 NIX_LDFLAGS = "-L${SDL2}/lib";
29
30 makeFlags = [
31 "LINKED_GTK=1"
32 "SDLCONFIG=${SDL2}/bin/sdl2-config"
33 "VC_REV=${rev}"
34 ];
35
36 desktopItem = makeDesktopItem {
37 name = "eduke32";
38 exec = "eduke32-wrapper";
39 comment = "Duke Nukem 3D port";
40 desktopName = "Enhanced Duke Nukem 3D";
41 genericName = "Duke Nukem 3D port";
42 categories = "Application;Game;";
43 };
44
45 installPhase = ''
46 # Make wrapper script
47 cat > eduke32-wrapper <<EOF
48 #!/bin/sh
49
50 if [ "$EDUKE32_DATA_DIR" = "" ]; then
51 EDUKE32_DATA_DIR=/var/lib/games/eduke32
52 fi
53 if [ "$EDUKE32_GRP_FILE" = "" ]; then
54 EDUKE32_GRP_FILE=\$EDUKE32_DATA_DIR/DUKE3D.GRP
55 fi
56
57 cd \$EDUKE32_DATA_DIR
58 exec $out/bin/eduke32 -g \$EDUKE32_GRP_FILE
59 EOF
60
61 # Install binaries
62 mkdir -p $out/bin
63 install -Dm755 eduke32{,-wrapper} mapster32 $out/bin
64
65 # Install desktop item
66 cp -rv ${desktopItem}/share $out
67 '';
68
69 meta = with stdenv.lib; {
70 description = "Enhanched port of Duke Nukem 3D for various platforms";
71 license = licenses.gpl2Plus;
72 homepage = http://eduke32.com;
73 maintainers = with maintainers; [ sander ];
74 platforms = with platforms; linux;
75 };
76}