@@ -1,76 +1,78 @@
1−{ stdenv, fetchurl, flac, gtk2, libvorbis, libvpx, makeDesktopItem, libGLU_combined, nasm
2−, pkgconfig, SDL2, SDL2_mixer, runtimeShell }:
1+{ stdenv, fetchurl, makeWrapper, pkgconfig, nasm, makeDesktopItem
2+, flac, gtk2, libvorbis, libvpx, libGLU_combined
3+, SDL2, SDL2_mixer }:
34
45let
5− year = "2015";
6− date = "20150420";
7− rev = "5160";
8−in stdenv.mkDerivation rec {
6+ version = "20190330";
7+ rev = "7470";
8+
9+ desktopItem = makeDesktopItem {
10+ name = "eduke32";
11+ exec = "@out@/bin/${wrapper}";
12+ comment = "Duke Nukem 3D port";
13+ desktopName = "Enhanced Duke Nukem 3D";
14+ genericName = "Duke Nukem 3D port";
15+ categories = "Application;Game;";
16+ };
17+
18+ wrapper = "eduke32-wrapper";
19+
20+in stdenv.mkDerivation {
921 name = "eduke32-${version}";
10− version = "${date}-${rev}";
1122
1223 src = fetchurl {
13− url = "http://dukeworld.duke4.net/eduke32/synthesis/old/${year}/${version}/eduke32_src_${version}.tar.xz";
14− sha256 = "1nlq5jbglg00c1z1vsyl627fh0mqfxvk5qyxav5vzla2b4svik2v";
24+ url = "http://dukeworld.duke4.net/eduke32/synthesis/latest/eduke32_src_${version}-${rev}.tar.xz";
25+ sha256 = "09a7l23i6sygicc82w1in9hjw0jvivlf7q0vw8kcx9j98lm23mkn";
1526 };
1627
17− buildInputs = [ flac gtk2 libvorbis libvpx libGLU_combined SDL2 SDL2_mixer ]
28+ buildInputs = [ flac gtk2 libvorbis libvpx libGLU_combined SDL2 SDL2_mixer ];
29+
30+ nativeBuildInputs = [ makeWrapper pkgconfig ]
1831 ++ stdenv.lib.optional (stdenv.hostPlatform.system == "i686-linux") nasm;
19− nativeBuildInputs = [ pkgconfig ];
2032
2133 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
34+ substituteInPlace source/build/src/glbuild.cpp \
35+ --replace libGLU.so ${libGLU_combined}/lib/libGLU.so
36+
37+ for f in glad.c glad_wgl.c ; do
38+ substituteInPlace source/glad/src/$f \
39+ --replace libGL.so ${libGLU_combined}/lib/libGL.so
40+ done
2541 '';
2642
27− NIX_CFLAGS_COMPILE = "-I${SDL2.dev}/include/SDL2 -I${SDL2_mixer}/include/SDL2";
28− NIX_LDFLAGS = "-L${SDL2}/lib";
43+ NIX_CFLAGS_COMPILE = [
44+ "-I${SDL2.dev}/include/SDL2"
45+ "-I${SDL2_mixer}/include/SDL2"
46+ ];
2947
3048 makeFlags = [
31− "LINKED_GTK=1"
3249 "SDLCONFIG=${SDL2}/bin/sdl2-config"
33− "VC_REV=${rev}"
3450 ];
3551
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− };
52+ enableParallelBuilding = true;
4453
4554 installPhase = ''
46− # Make wrapper script
47− cat > eduke32-wrapper <<EOF
48− #!${runtimeShell}
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
55+ runHook preInstall
56+
57+ install -Dm755 -t $out/bin eduke32 mapster32
58+
59+ makeWrapper $out/bin/eduke32 $out/bin/${wrapper} \
60+ --set-default EDUKE32_DATA_DIR /var/lib/games/eduke32 \
61+ --add-flags '-g "$EDUKE32_DATA_DIR/DUKE3D.GRP"'
62+
6663 cp -rv ${desktopItem}/share $out
64+ substituteInPlace $out/share/applications/eduke32.desktop \
65+ --subst-var out
66+
67+ runHook postInstall
6768 '';
6869
6970 meta = with stdenv.lib; {
7071 description = "Enhanched port of Duke Nukem 3D for various platforms";
71− license = licenses.gpl2Plus;
7272 homepage = http://eduke32.com;
73+ license = licenses.gpl2Plus;
7374 maintainers = with maintainers; [ sander ];
74− platforms = with platforms; linux;
75+ # Darwin is untested (supported by upstream)
76+ platforms = platforms.all;
7577 };
7678}