summary refs log tree commit diff
path: root/pkgs/games/terraria-server/default.nix
blob: 5432824ce6c0327b2dde15416ec007b33c683223 (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
{ stdenv, lib, file, fetchurl, unzip }:

stdenv.mkDerivation rec {
  pname = "terraria-server";
  version = "1.3.5.3";
  urlVersion = lib.replaceChars ["."] [""] version;

  src = fetchurl {
    url = "https://terraria.org/server/terraria-server-${urlVersion}.zip";
    sha256 = "0l7j2n6ip4hxph7dfal7kzdm3dqnm1wba6zc94gafkh97wr35ck3";
  };

  buildInputs = [ file unzip ];

  installPhase = ''
    mkdir -p $out/bin
    cp -r Linux $out/
    chmod +x "$out/Linux/TerrariaServer.bin.x86_64"
    ln -s "$out/Linux/TerrariaServer.bin.x86_64" $out/bin/TerrariaServer
    # Fix "/lib64/ld-linux-x86-64.so.2" like references in ELF executables.
    find "$out" | while read filepath; do
      if file "$filepath" | grep -q "ELF.*executable"; then
        echo "setting interpreter $(cat "$NIX_CC"/nix-support/dynamic-linker) in $filepath"
        patchelf --set-interpreter "$(cat "$NIX_CC"/nix-support/dynamic-linker)" "$filepath"
        test $? -eq 0 || { echo "patchelf failed to process $filepath"; exit 1; }
      fi
    done
  '';

  meta = with lib; {
    homepage = http://terraria.org;
    description = "Dedicated server for Terraria, a 2D action-adventure sandbox";
    platforms = ["x86_64-linux"];
    license = licenses.unfree;
  };
}