summary refs log tree commit diff
path: root/pkgs/games/xonotic/default.nix
blob: b6009ee72fd0df8f236060178558bc406117a82c (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
80
81
82
83
84
85
86
87
88
{ stdenv, fetchurl
, # required for both
  unzip, libjpeg, zlib, libvorbis, curl, patchelf
, # glx
  libX11, mesa, libXpm, libXext, libXxf86vm, alsaLib
, # sdl
  SDL2
}:

stdenv.mkDerivation rec {
  name = "xonotic-0.8.2";

  src = fetchurl {
    url = "http://dl.xonotic.org/${name}.zip";
    sha256 = "1mcs6l4clvn7ibfq3q69k2p0z6ww75rxvnngamdq5ic6yhq74bx2";
  };

  buildInputs = [
    # required for both
    unzip libjpeg
    # glx
    libX11 mesa libXpm libXext libXxf86vm alsaLib
    # sdl
    SDL2
    zlib libvorbis curl
  ];

  sourceRoot = "Xonotic/source/darkplaces";

  # "debug", "release", "profile"
  target = "release";

  dontStrip = target != "release";

  buildPhase = ''
    DP_FS_BASEDIR="$out/share/xonotic"
    make DP_FS_BASEDIR=$DP_FS_BASEDIR cl-${target}
    make DP_FS_BASEDIR=$DP_FS_BASEDIR sdl-${target}
    make DP_FS_BASEDIR=$DP_FS_BASEDIR sv-${target}
  '';
  enableParallelBuilding = true;

  installPhase = ''
    mkdir -p "$out/bin"
    cp darkplaces-dedicated "$out/bin/xonotic-dedicated"
    cp darkplaces-sdl "$out/bin/xonotic-sdl"
    cp darkplaces-glx "$out/bin/xonotic-glx"
    cd ../..
    mkdir -p "$out/share/xonotic"
    mv data "$out/share/xonotic"

    # default to sdl
    ln -s "$out/bin/xonotic-sdl" "$out/bin/xonotic"
  '';

  # Xonotic needs to find libcurl.so at runtime for map downloads
  dontPatchELF = true;
  postFixup = ''
    patchelf --add-needed ${curl.out}/lib/libcurl.so $out/bin/xonotic-dedicated
    patchelf \
        --add-needed ${curl.out}/lib/libcurl.so \
        --add-needed ${libvorbis}/lib/libvorbisfile.so \
        --add-needed ${libvorbis}/lib/libvorbis.so \
        $out/bin/xonotic-glx
    patchelf \
        --add-needed ${curl.out}/lib/libcurl.so \
        --add-needed ${libvorbis}/lib/libvorbisfile.so \
        --add-needed ${libvorbis}/lib/libvorbis.so \
        $out/bin/xonotic-sdl
  '';

  meta = {
    description = "A free fast-paced first-person shooter";
    longDescription = ''
      Xonotic is a free, fast-paced first-person shooter that works on
      Windows, OS X and Linux. The project is geared towards providing
      addictive arena shooter gameplay which is all spawned and driven
      by the community itself. Xonotic is a direct successor of the
      Nexuiz project with years of development between them, and it
      aims to become the best possible open-source FPS of its kind.
    '';
    homepage = http://www.xonotic.org;
    license = stdenv.lib.licenses.gpl2Plus;
    maintainers = with stdenv.lib.maintainers; [ astsmtl zalakain ];
    platforms = stdenv.lib.platforms.linux;
    hydraPlatforms = [];
  };
}