tailscale: build derpprobe (#364918)
[NixPkgs.git] / pkgs / by-name / it / itch / package.nix
blobc4ecd6f50950232543538ecc0ca5ca2ff457b295
2   lib,
3   stdenvNoCC,
4   fetchzip,
5   fetchFromGitHub,
6   electron,
7   steam-run,
8   makeWrapper,
9   copyDesktopItems,
10   makeDesktopItem,
13 let
14   version = "26.1.9";
15   butler = fetchzip {
16     url = "https://broth.itch.zone/butler/linux-amd64/15.21.0/butler.zip";
17     stripRoot = false;
18     hash = "sha256-jHni/5qf7xST6RRonP2EW8fJ6647jobzrnHe8VMx4IA=";
19   };
21   itch-setup = fetchzip {
22     url = "https://broth.itch.ovh/itch-setup/linux-amd64/1.26.0/itch-setup.zip";
23     stripRoot = false;
24     hash = "sha256-5MP6X33Jfu97o5R1n6Og64Bv4ZMxVM0A8lXeQug+bNA=";
25   };
27   sparseCheckout = "/release/images/itch-icons";
28   icons =
29     fetchFromGitHub {
30       owner = "itchio";
31       repo = "itch";
32       rev = "v${version}";
33       hash = "sha256-jugg+hdP0y0OkFhdQuEI9neWDuNf2p3+DQuwxe09Zck=";
34       sparseCheckout = [ sparseCheckout ];
35     }
36     + sparseCheckout;
38 stdenvNoCC.mkDerivation (finalAttrs: {
39   pname = "itch";
40   inherit version;
42   src = fetchzip {
43     url = "https://broth.itch.ovh/itch/linux-amd64/${finalAttrs.version}/archive/default#.zip";
44     stripRoot = false;
45     hash = "sha256-4k6afBgOKGs7rzXAtIBpmuQeeT/Va8/0bZgNYjuJhgI=";
46   };
48   nativeBuildInputs = [
49     copyDesktopItems
50     makeWrapper
51   ];
53   desktopItems = [
54     (makeDesktopItem {
55       name = "itch";
56       exec = "itch %U";
57       tryExec = "itch";
58       icon = "itch";
59       desktopName = "itch";
60       mimeTypes = [
61         "x-scheme-handler/itchio"
62         "x-scheme-handler/itch"
63       ];
64       comment = "Install and play itch.io games easily";
65       categories = [ "Game" ];
66     })
67   ];
69   # As taken from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=itch-bin
70   installPhase = ''
71     runHook preInstall
73     mkdir -p $out/bin $out/share/itch/resources/app
74     cp -r resources/app "$out/share/itch/resources/"
76     install -Dm644 LICENSE -t "$out/share/licenses/$pkgname/"
77     install -Dm644 LICENSES.chromium.html -t "$out/share/licenses/$pkgname/"
79     for icon in ${icons}/icon*.png
80     do
81       iconsize="''${icon#${icons}/icon}"
82       iconsize="''${iconsize%.png}"
83       icondir="$out/share/icons/hicolor/''${iconsize}x''${iconsize}/apps/"
84       install -Dm644 "$icon" "$icondir/itch.png"
85     done
87     runHook postInstall
88   '';
90   postFixup = ''
91     makeWrapper ${steam-run}/bin/steam-run $out/bin/itch \
92       --add-flags ${electron}/bin/electron \
93       --add-flags $out/share/itch/resources/app \
94       --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
95       --set BROTH_USE_LOCAL butler,itch-setup \
96       --prefix PATH : ${butler}:${itch-setup}
97   '';
99   meta = {
100     description = "Best way to play itch.io games";
101     homepage = "https://github.com/itchio/itch";
102     changelog = "https://github.com/itchio/itch/releases/tag/v${version}-canary";
103     license = lib.licenses.mit;
104     platforms = lib.platforms.linux;
105     sourceProvenance = [ lib.sourceTypes.binaryBytecode ];
106     maintainers = with lib.maintainers; [ pasqui23 ];
107     mainProgram = "itch";
108   };