1# copied from oh-my-git/package.nix by @jojosch (Johannes Schleifenbaum)
2# added in nixos/nixpkgs#119642
3{
4 lib,
5 autoPatchelfHook,
6 copyDesktopItems,
7 fetchFromGitHub,
8 makeDesktopItem,
9 stdenv,
10 alsa-lib,
11 godot3-export-templates,
12 godot3-headless,
13 libX11,
14 libXcursor,
15 libXext,
16 libXi,
17 libXinerama,
18 libXrandr,
19 libXrender,
20 libglvnd,
21 writableTmpDirAsHomeHook,
22}:
23stdenv.mkDerivation (finalAttrs: {
24 pname = "a-keys-path";
25 version = "0.7.1";
26
27 src = fetchFromGitHub {
28 owner = "geegaz";
29 repo = "A-Key-s-Path";
30 tag = "v${finalAttrs.version}";
31 hash = "sha256-i9INPB883/0fmtZgJpVpsA/7Q51DHOMWvkLF9hKE6gQ=";
32 };
33
34 nativeBuildInputs = [
35 autoPatchelfHook
36 copyDesktopItems
37 godot3-headless
38
39 # Cannot create file '/homeless-shelter/.config/godot/projects/...'
40 writableTmpDirAsHomeHook
41 ];
42
43 buildInputs = [
44 libX11
45 libXcursor
46 libXext
47 libXi
48 libXinerama
49 libXrandr
50 libXrender
51 libglvnd
52 ];
53
54 desktopItem = makeDesktopItem {
55 name = "a-keys-path";
56 exec = "a-keys-path";
57 icon = "a-keys-path";
58 desktopName = "a-keys-path";
59 comment = "A game where you build your way with your keys";
60 genericName = "A Key's Path";
61 categories = [ "Game" ];
62 };
63
64 buildPhase = ''
65 runHook preBuild
66
67 # Link the export-templates to the expected location. The --export commands
68 # expects the template-file at .../templates/3.2.3.stable/linux_x11_64_release
69 # with 3.2.3 being the version of godot.
70 mkdir -p $HOME/.local/share/godot
71 ln -s ${godot3-export-templates}/share/godot/templates $HOME/.local/share/godot
72
73 # export_presets.cfg copied here as it is .gitignored in source
74 # created by godot editor (godot3 -e) Project > Export... and add Linux
75 cp ${./export_presets.cfg} export_presets.cfg
76
77 mkdir -p $out/share/a-keys-path
78 godot3-headless --export "Linux" $out/share/a-keys-path/a-keys-path
79
80 runHook postBuild
81 '';
82
83 installPhase = ''
84 runHook preInstall
85
86 mkdir -p $out/bin
87 ln -s $out/share/a-keys-path/a-keys-path $out/bin
88
89 # Patch binaries.
90 interpreter=$(cat $NIX_CC/nix-support/dynamic-linker)
91 patchelf \
92 --set-interpreter $interpreter \
93 --set-rpath ${lib.makeLibraryPath finalAttrs.buildInputs} \
94 $out/share/a-keys-path/a-keys-path
95
96 mkdir -p $out/share/pixmaps
97 cp icon.png $out/share/pixmaps/a-keys-path.png
98
99 install -Dm644 ${finalAttrs.desktopItem}/share/applications/a-keys-path.desktop \
100 $out/share/applications/a-keys-path.desktop
101
102 runHook postInstall
103 '';
104
105 runtimeDependencies = map lib.getLib [
106 alsa-lib
107 ];
108
109 meta = {
110 homepage = "https://geegaz.itch.io/out-of-controls";
111 description = "Short puzzle-platformer game made with Godot, running on GLES 2.0";
112 mainProgram = "a-keys-path";
113 license = with lib.licenses; [
114 gpl3Only
115 cc-by-sa-40
116 cc0
117 ];
118 platforms = [ "x86_64-linux" ];
119 maintainers = with lib.maintainers; [ phanirithvij ];
120 };
121})