about summary refs log tree commit diff
path: root/pkgs/games/humblebundle/jamestown.nix
blob: 5148671cde260f885bf3b7369a8692c565092738 (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, fetchHumbleBundle, unzip, pkgsi686Linux, expect, makeWrapper
, SDL, openal
}:

let
  version = "1.0.2";
  usVersion = lib.replaceChars ["."] ["_"] version;
in stdenv.mkDerivation rec {
  name = "jamestown-${version}";

  src = fetchHumbleBundle {
    machineName = "jamestown_linux";
    downloadName = ".zip";
    suffix = "zip";
    md5 = "dcfb4348aba89f0f26bf5b4c7e05d936";
  };

  buildInputs = [ makeWrapper ];

  unpackPhase = ''
    ${unzip}/bin/unzip -q "$src"
    patchelf --set-interpreter "${pkgsi686Linux.glibc}"/lib/ld-linux.so.* \
      "JamestownInstaller_${usVersion}-bin"
    ${expect}/bin/expect <<INSTALL
    spawn "./JamestownInstaller_${usVersion}-bin"
    expect "see more?"
    send "n\r"
    expect "Accept this license?"
    send "y\r"
    expect "Press enter to continue."
    send "\r"
    expect "Enter path"
    send "$(pwd)/${name}\r"
    expect eof
    INSTALL
    sourceRoot="$(pwd)/${name}"
  '';

  installPhase = let
    rpath = lib.makeLibraryPath [ SDL openal ];
  in ''
    libexec="$out/libexec/jamestown"
    install -vD Jamestown-amd64 "$libexec/jamestown"

    mkdir -p "$out/share"
    mv Archives "$out/share/jamestown"

    makeWrapper "$(cat "$NIX_CC/nix-support/dynamic-linker")" \
      "$out/bin/jamestown" \
      --add-flags "$libexec/jamestown" \
      --set LD_LIBRARY_PATH "${rpath}"

    false # Both amd64 and i686 binaries are fucking BROKEN, wait for 1.0.3...
  '';
}