summaryrefslogtreecommitdiffstats
path: root/pkgs/development/tools/godot/export-templates-bin.nix
blob: 642af51dc9e81486a042f41d3bcc9a61cff2cfea (plain)
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
57
58
{
  fetchurl,
  godot,
  hash,
  lib,
  stdenvNoCC,
  unzip,
  version,
  withMono ? false,
}:
# Export templates is necessary for setting up Godot engine, it's used when exporting projects.
# Godot applications/games packages needs to reference export templates.
# Export templates version should be kept in sync with Godot version.
# https://docs.godotengine.org/en/stable/tutorials/export/exporting_projects.html#export-templates
let
  self = stdenvNoCC.mkDerivation {
    __structuredAttrs = true;

    pname = "godot-export-templates${lib.optionalString withMono "-mono"}-bin";
    version = version;

    src = fetchurl {
      url = "https://github.com/godotengine/godot/releases/download/${version}/Godot_v${version}${lib.optionalString withMono "_mono"}_export_templates.tpz";
      inherit hash;
    };

    nativeBuildInputs = [
      unzip
    ];

    strictDeps = true;

    unpackPhase = ''
      runHook preUnpack
      unzip -q "$src"
      runHook postUnpack
    '';

    installPhase = ''
      templates="$out"/share/godot/export_templates
      mkdir -p "$templates"
      read version < templates/version.txt
      mv templates "$templates/$version"
    '';

    meta = {
      inherit (godot.meta)
        changelog
        description
        homepage
        license
        maintainers
        ;
      sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
    };
  };
in
self