about summary refs log tree commit diff
path: root/pkgs/games
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2022-06-24 16:26:54 +0200
committerGitHub <noreply@github.com>2022-06-24 16:26:54 +0200
commite24ce21faa3d68c88da133a83be67d19bcbca03d (patch)
tree6512b8c041814c478043c5321e979af0e892d536 /pkgs/games
parent1b4b52253f2739a667201b84a5f2f2bae2fdf50f (diff)
parentb3080101af5fd937ee3ba6a6bfc60c4f3c5881d4 (diff)
Merge pull request #173613 from SuperSamus/itch
Diffstat (limited to 'pkgs/games')
-rw-r--r--pkgs/games/itch-setup/default.nix24
-rw-r--r--pkgs/games/itch/butler.nix29
-rw-r--r--pkgs/games/itch/default.nix85
3 files changed, 90 insertions, 48 deletions
diff --git a/pkgs/games/itch-setup/default.nix b/pkgs/games/itch-setup/default.nix
deleted file mode 100644
index 55d488bcaac06..0000000000000
--- a/pkgs/games/itch-setup/default.nix
+++ /dev/null
@@ -1,24 +0,0 @@
-{ lib, writeShellScriptBin, steam-run, fetchurl }:
-let
-
-  pname = "itch-setup";
-  version = "1.26.0";
-
-  src = fetchurl {
-    url = "https://broth.itch.ovh/itch-setup/linux-amd64/${version}/unpacked/default";
-    hash = "sha256-bcJKqhgZK42Irx12BIvbTDMb/DHEOEXljetlDokF7x8=";
-    executable = true;
-  };
-
-in
-(writeShellScriptBin pname ''exec ${steam-run}/bin/steam-run ${src} "$@"'') // {
-
-  passthru = { inherit pname version src; };
-  meta = with lib; {
-    description = "An installer for the itch.io desktop app";
-    homepage = "https://github.com/itchio/itch-setup";
-    license = licenses.mit;
-    platforms = platforms.linux;
-    maintainers = with maintainers; [ pasqui23 ];
-  };
-}
diff --git a/pkgs/games/itch/butler.nix b/pkgs/games/itch/butler.nix
new file mode 100644
index 0000000000000..68f1bac49e903
--- /dev/null
+++ b/pkgs/games/itch/butler.nix
@@ -0,0 +1,29 @@
+{ lib
+, buildGoModule
+, fetchFromGitHub
+}:
+
+buildGoModule rec {
+  pname = "butler";
+  version = "15.21.0";
+
+  src = fetchFromGitHub {
+    owner = "itchio";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "sha256-vciSmXR3wI3KcnC+Uz36AgI/WUfztA05MJv1InuOjJM=";
+  };
+
+  proxyVendor = true;
+
+  vendorSha256 = "sha256-EIl0ZFDKbZopUR22hp5a2vRUu0O1h1O953NrtoNa2x8=";
+
+  doCheck = false;
+
+  meta = with lib; {
+    description = "Command-line itch.io helper";
+    homepage = "https://github.com/itchio/butler";
+    license = licenses.mit;
+    maintainers = with maintainers; [ martfont ];
+  };
+}
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 ];
   };
 }