Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / games / itch / default.nix
blob897d8f3941c462c094fd655def8e1ce41b0e26a4
1 { lib
2 , stdenvNoCC
3 , fetchzip
4 , fetchFromGitHub
5 , butler
6 , electron
7 , steam-run
8 , makeWrapper
9 , copyDesktopItems
10 , makeDesktopItem
12 stdenvNoCC.mkDerivation rec {
13   pname = "itch";
14   version = "26.1.2";
16   # TODO: Using kitch instead of itch, revert when possible
17   src = fetchzip {
18     url = "https://broth.itch.ovh/k${pname}/linux-amd64/${version}/archive/default#.zip";
19     stripRoot = false;
20     sha256 = "sha256-thXe+glpltSiKNGIRgvOZQZPJWfDHWo3dLdziyp2BM4=";
21   };
23   itch-setup = fetchzip {
24     url = "https://broth.itch.ovh/itch-setup/linux-amd64/1.26.0/itch-setup.zip";
25     stripRoot = false;
26     sha256 = "sha256-5MP6X33Jfu97o5R1n6Og64Bv4ZMxVM0A8lXeQug+bNA=";
27   };
29   icons = let sparseCheckout = "/release/images/itch-icons"; in
30     fetchFromGitHub {
31         owner = "itchio";
32         repo = pname;
33         rev = "v${version}-canary";
34         sha256 = "sha256-veZiKs9qHge+gCEpJ119bAT56ssXJAH3HBcYkEHqBFg=";
35         sparseCheckout = [ sparseCheckout ];
36       } + sparseCheckout;
38   nativeBuildInputs = [ copyDesktopItems makeWrapper ];
40   desktopItems = [
41     (makeDesktopItem {
42       name = pname;
43       exec = "itch %U";
44       tryExec = pname;
45       icon = pname;
46       desktopName = pname;
47       mimeTypes = [ "x-scheme-handler/itchio" "x-scheme-handler/itch" ];
48       comment = "Install and play itch.io games easily";
49       categories = [ "Game" ];
50     })
51   ];
53   # As taken from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=itch-bin
54   installPhase = ''
55     runHook preInstall
57     # TODO: Remove when the next stable Itch is stabilized
58     substituteInPlace ./resources/app/package.json \
59       --replace "kitch" "itch"
61     mkdir -p $out/bin $out/share/${pname}/resources/app
62     cp -r resources/app "$out/share/${pname}/resources/"
64     install -Dm644 LICENSE -t "$out/share/licenses/$pkgname/"
65     install -Dm644 LICENSES.chromium.html -t "$out/share/licenses/$pkgname/"
67     for icon in $icons/icon*.png
68     do
69       iconsize="''${icon#$icons/icon}"
70       iconsize="''${iconsize%.png}"
71       icondir="$out/share/icons/hicolor/''${iconsize}x''${iconsize}/apps/"
72       install -Dm644 "$icon" "$icondir/itch.png"
73     done
75     runHook postInstall
76   '';
78   postFixup = ''
79     makeWrapper ${steam-run}/bin/steam-run $out/bin/${pname} \
80       --add-flags ${electron}/bin/electron \
81       --add-flags $out/share/${pname}/resources/app \
82       --set BROTH_USE_LOCAL butler,itch-setup \
83       --prefix PATH : ${butler}/bin/:${itch-setup}
84   '';
86   meta = with lib; {
87     description = "The best way to play itch.io games";
88     homepage = "https://github.com/itchio/itch";
89     license = licenses.mit;
90     platforms = platforms.linux;
91     sourceProvenance = [ lib.sourceTypes.binaryBytecode ];
92     maintainers = with maintainers; [ pasqui23 ];
93   };