about summary refs log tree commit diff
path: root/pkgs/games/itch/invisigun-heroes.nix
blob: 04fd06a8f3a833f98e352b807e5359fcc054e6f2 (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
{ stdenv, fetchItch, unzip, mesa, xorg, libpulseaudio, libudev
, gtk2-x11, gdk_pixbuf, glib
}:

stdenv.mkDerivation rec {
  name = "invisigun-heroes-${version}";
  version = "1.5.30";

  src = fetchItch {
    name = "${name}.zip";
    gameId = 25561;
    uploadId = 208583;
    version = "v${version}";
    sha256 = "07iskccdmygnx70naaa3fcac1ayrhmq82cypddsnihc3gkw7rwrd";
  };

  unpackCmd = ''
    ${unzip}/bin/unzip -qq -d invisigun-heroes "$src" || :
  '';

  arch = if stdenv.system == "x86_64-linux" then "x86_64" else "x86";
  executable = "Invisigun Heroes.${arch}";

  buildPhase = let
    rpath = stdenv.lib.makeLibraryPath [
      stdenv.cc.cc mesa xorg.libX11 xorg.libXcursor xorg.libXrandr
      libpulseaudio libudev
    ];

    ssRpath = stdenv.lib.makeLibraryPath [
      stdenv.cc.cc gtk2-x11 gdk_pixbuf glib
    ];
  in ''
    patchelf \
      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
      --set-rpath ${stdenv.lib.escapeShellArg rpath} "$executable"

    patchelf --set-rpath ${stdenv.lib.escapeShellArg ssRpath} \
      "Invisigun Heroes_Data/Plugins/x86_64/ScreenSelector.so"
  '';

  installPhase = ''
    install -vD "$executable" "$out/libexec/invisigun-heroes/invisigun-heroes"
    ln -s "$out/share/invisigun-heroes" "$out/libexec/invisigun-heroes/Data"

    mkdir -p "$out/bin"
    ln -s "$out/libexec/invisigun-heroes/invisigun-heroes" \
          "$out/bin/invisigun-heroes"

    mkdir -p "$out/share"
    cp -vRd "Invisigun Heroes_Data" "$out/share/invisigun-heroes"
  '';

  dontStrip = true;
  dontPatchELF = true;
}