summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/a-/a-keys-path/package.nix
blob: ef202b520e1b5c9b0efd43784488d61d5b4adc34 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# copied from oh-my-git/package.nix by @jojosch (Johannes Schleifenbaum)
# added in nixos/nixpkgs#119642
{
  lib,
  autoPatchelfHook,
  copyDesktopItems,
  fetchFromGitHub,
  makeDesktopItem,
  stdenv,
  alsa-lib,
  godot3-export-templates,
  godot3-headless,
  libx11,
  libxcursor,
  libxext,
  libxi,
  libxinerama,
  libxrandr,
  libxrender,
  libglvnd,
  writableTmpDirAsHomeHook,
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "a-keys-path";
  version = "0.7.1";

  src = fetchFromGitHub {
    owner = "geegaz";
    repo = "A-Key-s-Path";
    tag = "v${finalAttrs.version}";
    hash = "sha256-i9INPB883/0fmtZgJpVpsA/7Q51DHOMWvkLF9hKE6gQ=";
  };

  nativeBuildInputs = [
    autoPatchelfHook
    copyDesktopItems
    godot3-headless

    # Cannot create file '/homeless-shelter/.config/godot/projects/...'
    writableTmpDirAsHomeHook
  ];

  buildInputs = [
    libx11
    libxcursor
    libxext
    libxi
    libxinerama
    libxrandr
    libxrender
    libglvnd
  ];

  desktopItem = makeDesktopItem {
    name = "a-keys-path";
    exec = "a-keys-path";
    icon = "a-keys-path";
    desktopName = "a-keys-path";
    comment = "A game where you build your way with your keys";
    genericName = "A Key's Path";
    categories = [ "Game" ];
  };

  buildPhase = ''
    runHook preBuild

    # Link the export-templates to the expected location. The --export commands
    # expects the template-file at .../templates/3.2.3.stable/linux_x11_64_release
    # with 3.2.3 being the version of godot.
    mkdir -p $HOME/.local/share/godot
    ln -s ${godot3-export-templates}/share/godot/templates $HOME/.local/share/godot

    # export_presets.cfg copied here as it is .gitignored in source
    # created by godot editor (godot3 -e) Project > Export... and add Linux
    cp ${./export_presets.cfg} export_presets.cfg

    mkdir -p $out/share/a-keys-path
    godot3-headless --export "Linux" $out/share/a-keys-path/a-keys-path

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    ln -s $out/share/a-keys-path/a-keys-path $out/bin

    # Patch binaries.
    interpreter=$(cat $NIX_CC/nix-support/dynamic-linker)
    patchelf \
      --set-interpreter $interpreter \
      --set-rpath ${lib.makeLibraryPath finalAttrs.buildInputs} \
      $out/share/a-keys-path/a-keys-path

    install -D icon.png $out/share/icons/hicolor/256x256/apps/a-keys-path.png

    install -Dm644 ${finalAttrs.desktopItem}/share/applications/a-keys-path.desktop \
      $out/share/applications/a-keys-path.desktop

    runHook postInstall
  '';

  runtimeDependencies = map lib.getLib [
    alsa-lib
  ];

  meta = {
    homepage = "https://geegaz.itch.io/out-of-controls";
    description = "Short puzzle-platformer game made with Godot, running on GLES 2.0";
    mainProgram = "a-keys-path";
    license = with lib.licenses; [
      gpl3Only
      cc-by-sa-40
      cc0
    ];
    platforms = [ "x86_64-linux" ];
    maintainers = with lib.maintainers; [ phanirithvij ];
  };
})