summary refs log tree commit diff
path: root/pkgs/games/eduke32/default.nix
blob: e305505d62cbccc1b8655dbc72caaf830f3e8b78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{ stdenv, fetchurl, makeWrapper, pkgconfig, nasm, makeDesktopItem
, flac, gtk2, libvorbis, libvpx, libGLU, libGL
, SDL2, SDL2_mixer }:

let
  version = "20190330";
  rev = "7470";

  desktopItem = makeDesktopItem {
    name = "eduke32";
    exec = "@out@/bin/${wrapper}";
    comment = "Duke Nukem 3D port";
    desktopName = "Enhanced Duke Nukem 3D";
    genericName = "Duke Nukem 3D port";
    categories = "Application;Game;";
  };

  wrapper = "eduke32-wrapper";

in stdenv.mkDerivation {
  pname = "eduke32";
  inherit version;

  src = fetchurl {
    url = "http://dukeworld.duke4.net/eduke32/synthesis/latest/eduke32_src_${version}-${rev}.tar.xz";
    sha256 = "09a7l23i6sygicc82w1in9hjw0jvivlf7q0vw8kcx9j98lm23mkn";
  };

  buildInputs = [ flac gtk2 libvorbis libvpx libGL libGLU SDL2 SDL2_mixer ];

  nativeBuildInputs = [ makeWrapper pkgconfig ]
    ++ stdenv.lib.optional (stdenv.hostPlatform.system == "i686-linux") nasm;

  postPatch = ''
    substituteInPlace source/build/src/glbuild.cpp \
      --replace libGLU.so ${libGLU}/lib/libGLU.so

    for f in glad.c glad_wgl.c ; do
      substituteInPlace source/glad/src/$f \
        --replace libGL.so ${libGL}/lib/libGL.so
    done
  '';

  NIX_CFLAGS_COMPILE = [
    "-I${SDL2.dev}/include/SDL2"
    "-I${SDL2_mixer}/include/SDL2"
  ];

  makeFlags = [
    "SDLCONFIG=${SDL2}/bin/sdl2-config"
  ];

  enableParallelBuilding = true;

  installPhase = ''
    runHook preInstall

    install -Dm755 -t $out/bin eduke32 mapster32

    makeWrapper $out/bin/eduke32 $out/bin/${wrapper} \
      --set-default EDUKE32_DATA_DIR /var/lib/games/eduke32 \
      --add-flags '-g "$EDUKE32_DATA_DIR/DUKE3D.GRP"'

    cp -rv ${desktopItem}/share $out
    substituteInPlace $out/share/applications/eduke32.desktop \
      --subst-var out

    runHook postInstall
  '';

  meta = with stdenv.lib; {
    description = "Enhanched port of Duke Nukem 3D for various platforms";
    homepage = http://eduke32.com;
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ sander ];
    # Darwin is untested (supported by upstream)
    platforms = platforms.all;
  };
}