about summary refs log tree commit diff
path: root/pkgs/games/humblebundle/cavestoryplus.nix
blob: a549ebfb2ffa2c0ee8df6437b22aaf93f005b3e2 (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
{ stdenv, fetchHumbleBundle, makeWrapper, SDL, libGL }:

stdenv.mkDerivation rec {
  name = "cave-story-plus-${version}";
  version = "r100";

  src = fetchHumbleBundle {
    machineName = "cavestoryplus_linux";
    downloadName = ".tar.bz2";
    suffix = "tar.bz2";
    md5 = "b7ecd65644b8607bc177d7ce670f2185";
  };

  buildInputs = [ makeWrapper ];

  patchPhase = let
    rpath = stdenv.lib.makeLibraryPath [
      SDL "$out" stdenv.cc.cc libGL
    ];
  in ''
    patchelf \
      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
      --set-rpath "${rpath}" CaveStory+_64
  '';

  installPhase = ''
    install -vD CaveStory+_64 "$out/libexec/cave-story-plus/cave-story-plus"
    mkdir -p "$out/bin"
    makeWrapper \
      "$out/libexec/cave-story-plus/cave-story-plus" \
      "$out/bin/cave-story-plus" \
      --run "cd '$out/share/cave-story-plus'"

    mkdir -p "$out/share/cave-story-plus"
    cp -vrt "$out/share/cave-story-plus" data
  '';

  dontStrip = true;
}