summary refs log tree commit diff
path: root/pkgs/games/ecwolf/default.nix
blob: b7bb382db835aba3288b2b389003e32261403590 (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
{stdenv, lib, fetchurl, makeDesktopItem, copyDesktopItems, cmake, pkg-config, zlib, bzip2, libjpeg, SDL, SDL_mixer, gtk2}:

let
  desktopItem = makeDesktopItem {
    name = "ecwolf";
    exec = "ecwolf";
    comment = "Enhanced Wolfenstein 3D port";
    desktopName = "Wolfenstein 3D";
    categories = "Game;";
  };
in
stdenv.mkDerivation rec {
  pname = "ecwolf";
  version = "1.3.3";

  src = fetchurl {
    url = "https://maniacsvault.net/ecwolf/files/ecwolf/1.x/${pname}-${version}-src.tar.xz";
    sha256 = "1sbdv672dz47la5a5qwmdi1v258k9kc5dkx7cdj2b6gk8nbm2srl";
  };

  nativeBuildInputs = [ cmake pkg-config ];
  buildInputs = [ zlib bzip2 libjpeg SDL SDL_mixer gtk2 copyDesktopItems ];

  desktopItems = [ desktopItem ];

  # Change the location where the ecwolf executable looks for the ecwolf.pk3
  # file.
  #
  # By default, it expects the PK3 file to reside in the same directory as the
  # executable, which is not desirable.
  # We will adjust the code so that it can be retrieved from the share/
  # directory.

  preConfigure = ''
    sed -i -e "s|ecwolf.pk3|$out/share/ecwolf/ecwolf.pk3|" src/version.h
  ''
  # Disable app bundle creation on Darwin. It fails, and it is not needed to run it from the Nix store
  + lib.optionalString (stdenv.isDarwin) ''
    sed -i -e "s|include(\''${CMAKE_CURRENT_SOURCE_DIR}/macosx/install.txt)||" src/CMakeLists.txt
  '';

  # Install the required PK3 file in the required data directory
  postInstall = ''
    mkdir -p $out/share/ecwolf
    cp ecwolf.pk3 $out/share/ecwolf
  '';

  meta = with lib; {
    description = "Enhanched SDL-based port of Wolfenstein 3D for various platforms";
    homepage = "https://maniacsvault.net/ecwolf/";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ sander ];
    platforms = platforms.all;
  };
}