lol
1{
2 lib,
3 autoPatchelfHook,
4 copyDesktopItems,
5 fetchFromGitHub,
6 makeDesktopItem,
7 stdenv,
8 alsa-lib,
9 gcc-unwrapped,
10 git,
11 godot3-export-templates,
12 godot3-headless,
13 libGLU,
14 libX11,
15 libXcursor,
16 libXext,
17 libXfixes,
18 libXi,
19 libXinerama,
20 libXrandr,
21 libXrender,
22 libglvnd,
23 libpulseaudio,
24 perl,
25 zlib,
26 udev, # for libudev
27}:
28
29stdenv.mkDerivation rec {
30 pname = "oh-my-git";
31 version = "0.6.5";
32
33 src = fetchFromGitHub {
34 owner = "git-learning-game";
35 repo = "oh-my-git";
36 rev = version;
37 sha256 = "sha256-XqxliMVU55D5JSt7Yo5btvZnnTlagSukyhXv6Akgklo=";
38 };
39
40 nativeBuildInputs = [
41 autoPatchelfHook
42 copyDesktopItems
43 godot3-headless
44 ];
45
46 buildInputs = [
47 alsa-lib
48 gcc-unwrapped.lib
49 git
50 libGLU
51 libX11
52 libXcursor
53 libXext
54 libXfixes
55 libXi
56 libXinerama
57 libXrandr
58 libXrender
59 libglvnd
60 libpulseaudio
61 perl
62 zlib
63 udev
64 ];
65
66 desktopItems = [
67 (makeDesktopItem {
68 name = "oh-my-git";
69 exec = "oh-my-git";
70 icon = "oh-my-git";
71 desktopName = "oh-my-git";
72 comment = "An interactive Git learning game!";
73 genericName = "An interactive Git learning game!";
74 categories = [ "Game" ];
75 })
76 ];
77
78 # patch shebangs so that e.g. the fake-editor script works:
79 # error: /usr/bin/env 'perl': No such file or directory
80 # error: There was a problem with the editor
81 postPatch = ''
82 patchShebangs scripts
83 '';
84
85 buildPhase = ''
86 runHook preBuild
87
88 # Cannot create file '/homeless-shelter/.config/godot/projects/...'
89 export HOME=$TMPDIR
90
91 # Link the export-templates to the expected location. The --export commands
92 # expects the template-file at .../templates/3.2.3.stable/linux_x11_64_release
93 # with 3.2.3 being the version of godot.
94 mkdir -p $HOME/.local/share/godot
95 ln -s ${godot3-export-templates}/share/godot/templates $HOME/.local/share/godot
96
97 mkdir -p $out/share/oh-my-git
98 godot3-headless --export "Linux" $out/share/oh-my-git/oh-my-git
99
100 runHook postBuild
101 '';
102
103 installPhase = ''
104 runHook preInstall
105
106 mkdir -p $out/bin
107 ln -s $out/share/oh-my-git/oh-my-git $out/bin
108
109 # Patch binaries.
110 interpreter=$(cat $NIX_CC/nix-support/dynamic-linker)
111 patchelf \
112 --set-interpreter $interpreter \
113 --set-rpath ${lib.makeLibraryPath buildInputs} \
114 $out/share/oh-my-git/oh-my-git
115
116 mkdir -p $out/share/pixmaps
117 cp images/oh-my-git.png $out/share/pixmaps/oh-my-git.png
118
119 runHook postInstall
120 '';
121
122 runtimeDependencies = map lib.getLib [
123 alsa-lib
124 libpulseaudio
125 udev
126 ];
127
128 meta = with lib; {
129 homepage = "https://ohmygit.org/";
130 description = "Interactive Git learning game";
131 mainProgram = "oh-my-git";
132 license = with licenses; [ blueOak100 ];
133 platforms = [ "x86_64-linux" ];
134 maintainers = with maintainers; [ jojosch ];
135 };
136}