summary refs log tree commit diff
path: root/pkgs/games/oh-my-git/default.nix
blob: 0da53bbf9aa1cc1b631e8b582eb3e91643d0d685 (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
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
121
122
123
124
125
126
{ lib
, copyDesktopItems
, fetchFromGitHub
, makeDesktopItem
, stdenv
, alsa-lib
, gcc-unwrapped
, git
, godot-export-templates
, godot-headless
, libGLU
, libX11
, libXcursor
, libXext
, libXfixes
, libXi
, libXinerama
, libXrandr
, libXrender
, libglvnd
, libpulseaudio
, perl
, zlib
, udev # for libudev
}:

stdenv.mkDerivation rec {
  pname = "oh-my-git";
  version = "0.6.4";

  src = fetchFromGitHub {
    owner = "git-learning-game";
    repo = "oh-my-git";
    rev = version;
    sha256 = "sha256-GQLHyBUXF+yqEZ/LYutAn6TBCXFX8ViOaERQEm2J6CY=";
  };

  nativeBuildInputs = [
    copyDesktopItems
    godot-headless
  ];

  buildInputs = [
    alsa-lib
    gcc-unwrapped.lib
    git
    libGLU
    libX11
    libXcursor
    libXext
    libXfixes
    libXi
    libXinerama
    libXrandr
    libXrender
    libglvnd
    libpulseaudio
    perl
    zlib
    udev
  ];

  desktopItems = [
    (makeDesktopItem {
      name = "oh-my-git";
      exec = "oh-my-git";
      icon = "oh-my-git";
      desktopName = "oh-my-git";
      comment = "An interactive Git learning game!";
      genericName = "An interactive Git learning game!";
      categories = [ "Game" ];
    })
  ];

  # patch shebangs so that e.g. the fake-editor script works:
  # error: /usr/bin/env 'perl': No such file or directory
  # error: There was a problem with the editor
  postPatch = ''
    patchShebangs scripts
  '';

  buildPhase = ''
    runHook preBuild

    # Cannot create file '/homeless-shelter/.config/godot/projects/...'
    export HOME=$TMPDIR

    # 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 ${godot-export-templates}/share/godot/templates $HOME/.local/share/godot

    mkdir -p $out/share/oh-my-git
    godot-headless --export "Linux" $out/share/oh-my-git/oh-my-git

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    ln -s $out/share/oh-my-git/oh-my-git $out/bin

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

    mkdir -p $out/share/pixmaps
    cp images/oh-my-git.png $out/share/pixmaps/oh-my-git.png

    runHook postInstall
  '';

  meta = with lib; {
    homepage = "https://ohmygit.org/";
    description = "An interactive Git learning game";
    license = with licenses; [ blueOak100 ];
    platforms   = [ "x86_64-linux" ];
    maintainers = with maintainers; [ jojosch ];
  };
}