about summary refs log tree commit diff
path: root/pkgs/games/itch/invisigun-heroes.nix
blob: 15aba338bb2e3f3e17b50dabe86ecc1256721f38 (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
{ buildUnity, fetchItch, mono, monogamePatcher, strace }:

buildUnity rec {
  name = "invisigun-heroes";
  fullName = "Invisigun";
  saveDir = "Sombr Studio/Invisigun Reloaded";
  version = "1.7.16";

  src = fetchItch {
    name = "${name}-${version}.zip";
    gameId = 25561;
    uploadId = 208583;
    version = "v${version}";
    sha256 = "1flwc5wvw84s53my8v8n402iz6izjs4d4ppffajdv9cg1vs3nbpl";
  };

  nativeBuildInputs = [ mono monogamePatcher ];

  buildPhase = ''
    cat > nix-support.cs <<EOF
    using UnityEngine;

    public class NixSupport {
      public static string GetFullPathStub(string _ignore) {
        return Application.persistentDataPath;
      }
    }
    EOF

    mcs nix-support.cs -target:library \
      -r:Invisigun_Data/Managed/UnityEngine.CoreModule \
      -out:Invisigun_Data/Managed/NixSupport.dll

    monogame-patcher replace-call \
      -i Invisigun_Data/Managed/Assembly-CSharp.dll \
      -a Invisigun_Data/Managed/NixSupport.dll \
      'System.String System.IO.Path::GetFullPath(System.String)' \
      'System.String NixSupport::GetFullPathStub(System.String)' \
      FileManagerAdapter_Desktop::ApplicationPath
  '';

  sandbox.paths.required = [ "$HOME/Invisigun Heroes" ];
}