about summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authorMartino Fontana <tinozzo123@tutanota.com>2022-06-02 21:29:40 +0200
committerMartino Fontana <tinozzo123@tutanota.com>2022-06-22 14:58:28 +0200
commitdeabb657a28f8c84226ac6a630bb0ce20c38e5b4 (patch)
tree1adca8f106db3c040dd8c2ce934aff0e9036bc32 /pkgs/games
parente9b39ae01c1af6f4be2359a19c0817656412d82c (diff)
itch: install binary in system
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/itch/default.nix85
1 files changed, 61 insertions, 24 deletions
diff --git a/pkgs/games/itch/default.nix b/pkgs/games/itch/default.nix
index 34a2775c3c80c..991623b6c9f7e 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 -- "$@"
-  '';
+  # As taken from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=itch-bin
+  installPhase = ''
+    runHook preInstall
 
-  passAsFile = [ "itchBin" ];
+    mkdir -p $out/bin $out/share/${pname}/resources/app
+    cp -r resources/app "$out/share/${pname}/resources/"
 
-  # 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
+    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 ];
   };
 }