about summary refs log tree commit diff
path: root/pkgs/games/build-support/monogame-patcher/default.nix
blob: fffa6825651e3b934ade19feff3f393e554ab040 (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
{ lib, runCommand, makeWrapper, fetchNuGet, mono, dotnetPackages }:

runCommand "monogame-patcher" {
  nativeBuildInputs = [ mono makeWrapper ];

  src = ./patcher.cs;

  cecil = "${fetchNuGet {
    baseName = "Mono.Cecil";
    version = "0.10-beta7";
    sha256 = "03bina3llcnylrfrvp5psnwrfn757j7zch5r360rpdn7gmcjjcpl";
    outputFiles = [ "lib/net40/*" ];
  }}/lib/dotnet/Mono.Cecil";

  cliparser = "${fetchNuGet {
    baseName = "CommandLineParser";
    version = "2.2.1";
    sha256 = "0wf8mzr16d2ni008m60rrk738v8ypk74llk6g8mlyx7rrlchnxaf";
    outputFiles = [ "lib/net45/*" ];
  }}/lib/dotnet/CommandLineParser";

} ''
  mkdir -p "$out/bin" "$out/libexec/monogame-patcher"
  mcs "$src" -out:"$out/libexec/monogame-patcher/patcher.exe" \
    -lib:"$cecil" -lib:"$cliparser" \
    -r:Mono.Cecil -r:Mono.Cecil.Rocks -r:CommandLine

  makeWrapper ${lib.escapeShellArg "${mono}/bin/mono"} "$out/bin/$name" \
    --set MONO_PATH "$cecil:$cliparser" \
    --add-flags "$out/libexec/monogame-patcher/patcher.exe"
''