about summary refs log tree commit diff
path: root/nixpkgs/pkgs/games/itch/default.nix
blob: a8cfe8f24d76b8708d2dacb8ffc22041b2872a9f (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
{ lib
, stdenvNoCC
, fetchurl
, libnotify
, nss
, gtk3
, fetchFromGitHub
, makeDesktopItem
, itch-setup
, runtimeShell
}:
stdenvNoCC.mkDerivation rec{
  pname = "itch";
  version = "25.5.1";

  src = fetchFromGitHub {
    owner = "itchio";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-Pi3l3uK4kr+N3p7fGQuqckYIzycRqJHDVX00reoSbp4=";
  };

  desktopItems = [
    (makeDesktopItem {
      name = pname;
      exec = pname;
      icon = pname;
      desktopName = pname;
      mimeType = "x-scheme-handler/itchio;x-scheme-handler/itch";
      comment = "Install and play itch.io games easily";
      extraDesktopEntries = {
        TryExec = "itch %U";
        Categories = "Game;";
      };
    })
  ];

  itchBin = ''
    #!${runtimeShell}
    exec ${itch-setup}/bin/itch-setup --prefer-launch -- "$@"
  '';

  passAsFile = [ "itchBin" ];

  # as taken from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=itch
  installPhase = ''
    install -Dm0777 $itchBinPath $out/bin/itch
    for icon in release/images/itch-icons/icon*.png
    do
      iconsize="''${icon#release/images/itch-icons/icon}"
      iconsize="''${iconsize%.png}"
      icondir="$out/share/icons/hicolor/''${iconsize}x''${iconsize}/apps/"
      install -Dm644 "$icon" "$icondir/itch.png"
    done
  '';

  meta = with lib; {
    description = "The best way to play itch.io games";
    homepage = "https://github.com/itchio/itch";
    license = licenses.mit;
    platforms = platforms.linux;
    maintainers = with maintainers; [ pasqui23 ];
  };
}