diff --git a/pkgs/games/itch/default.nix b/pkgs/games/itch/default.nix index 34a2775c3c80..991623b6c9f7 100644 --- a/pkgs/games/itch/default.nix +++ b/pkgs/games/itch/default.nix @@ -1,30 +1,56 @@ { lib , stdenvNoCC -, fetchurl -, libnotify -, nss -, gtk3 +, fetchpatch +, fetchzip , fetchFromGitHub +, butler +, electron_11 +, steam-run +, makeWrapper +, copyDesktopItems , makeDesktopItem -, itch-setup -, runtimeShell }: -stdenvNoCC.mkDerivation rec{ +stdenvNoCC.mkDerivation rec { pname = "itch"; version = "25.5.1"; - src = fetchFromGitHub { - owner = "itchio"; - repo = pname; - rev = "v${version}"; - hash = "sha256-Pi3l3uK4kr+N3p7fGQuqckYIzycRqJHDVX00reoSbp4="; + src = fetchzip { + url = "https://broth.itch.ovh/${pname}/linux-amd64/${version}/itch.zip"; + stripRoot = false; + sha256 = "sha256-ejfS+sqhacW2h8u96W4fout3V8xrBs0SrW5w/7X83m4="; }; + patches = [ + # Fixes crash while browsing the store. + (fetchpatch { + name = "itch.patch"; + url = "https://aur.archlinux.org/cgit/aur.git/plain/itch.patch?h=itch-bin&id=0b181454567029141749f870880b10093216e133"; + sha256 = "sha256-gmLL/BMondSflERm0z+DuGDP56JhDXiyxEwLUavTD8Q="; + }) + ]; + + itch-setup = fetchzip { + url = "https://broth.itch.ovh/itch-setup/linux-amd64/1.26.0/itch-setup.zip"; + stripRoot = false; + sha256 = "sha256-5MP6X33Jfu97o5R1n6Og64Bv4ZMxVM0A8lXeQug+bNA="; + }; + + icons = let sparseCheckout = "/release/images/itch-icons"; in + fetchFromGitHub { + owner = "itchio"; + repo = pname; + rev = "v${version}"; + hash = "sha256-1L6STTBHA9xL9IaERaH2OTvurTSng1D+P3KoW0ucEJc="; + inherit sparseCheckout; + } + sparseCheckout; + + nativeBuildInputs = [ copyDesktopItems makeWrapper ]; + desktopItems = [ (makeDesktopItem { name = pname; - exec = pname; - tryExec = "itch %U"; + exec = "itch %U"; + tryExec = pname; icon = pname; desktopName = pname; mimeTypes = [ "x-scheme-handler/itchio" "x-scheme-handler/itch" ]; @@ -33,23 +59,33 @@ stdenvNoCC.mkDerivation rec{ }) ]; - 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 + # As taken from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=itch-bin installPhase = '' - install -Dm0777 $itchBinPath $out/bin/itch - for icon in release/images/itch-icons/icon*.png + runHook preInstall + + mkdir -p $out/bin $out/share/${pname}/resources/app + cp -r resources/app "$out/share/${pname}/resources/" + + install -Dm644 LICENSE -t "$out/share/licenses/$pkgname/" + install -Dm644 LICENSES.chromium.html -t "$out/share/licenses/$pkgname/" + + for icon in $icons/icon*.png do - iconsize="''${icon#release/images/itch-icons/icon}" + iconsize="''${icon#$icons/icon}" iconsize="''${iconsize%.png}" icondir="$out/share/icons/hicolor/''${iconsize}x''${iconsize}/apps/" install -Dm644 "$icon" "$icondir/itch.png" done + + runHook postInstall + ''; + + postFixup = '' + makeWrapper ${steam-run}/bin/steam-run $out/bin/${pname} \ + --add-flags ${electron_11}/bin/electron \ + --add-flags $out/share/${pname}/resources/app \ + --set BROTH_USE_LOCAL butler,itch-setup \ + --prefix PATH : ${butler}/bin/:${itch-setup} ''; meta = with lib; { @@ -57,6 +93,7 @@ stdenvNoCC.mkDerivation rec{ homepage = "https://github.com/itchio/itch"; license = licenses.mit; platforms = platforms.linux; + sourceProvenance = lib.sourceTypes.binaryBytecode; maintainers = with maintainers; [ pasqui23 ]; }; }