about summary refs log tree commit diff
path: root/pkgs/by-name/te/tetrio-desktop/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/te/tetrio-desktop/package.nix')
-rw-r--r--pkgs/by-name/te/tetrio-desktop/package.nix103
1 files changed, 45 insertions, 58 deletions
diff --git a/pkgs/by-name/te/tetrio-desktop/package.nix b/pkgs/by-name/te/tetrio-desktop/package.nix
index d7fed29e7dae7..f07299b37cc39 100644
--- a/pkgs/by-name/te/tetrio-desktop/package.nix
+++ b/pkgs/by-name/te/tetrio-desktop/package.nix
@@ -1,84 +1,70 @@
 { stdenv
 , lib
-, fetchurl
+, fetchzip
 , dpkg
-, autoPatchelfHook
-, wrapGAppsHook
-, alsa-lib
-, cups
-, libGL
-, libX11
-, libXScrnSaver
-, libXtst
-, mesa
-, nss
-, gtk3
-, libpulseaudio
-, systemd
-, withTetrioPlus ? false # For backwards compatibility. At the time of writing, the latest released tetrio plus version is not compatible with tetrio desktop.
-, tetrio-plus ? false # For backwards compatibility. At the time of writing, the latest released tetrio plus version is not compatible with tetrio desktop.
+, makeWrapper
+, callPackage
+, addOpenGLRunpath
+, electron
+, withTetrioPlus ? false
+, tetrio-plus ? null
 }:
 
-lib.warnIf (withTetrioPlus != false) "withTetrioPlus: Currently unsupported with tetrio-desktop 9.0.0. Please remove this attribute."
-lib.warnIf (tetrio-plus != false) "tetrio-plus: Currently unsupported with tetrio-desktop 9.0.0. Please remove this attribute."
-
-(let
-  libPath = lib.makeLibraryPath [
-    libGL
-    libpulseaudio
-    systemd
-  ];
-in
 stdenv.mkDerivation (finalAttrs: {
   pname = "tetrio-desktop";
   version = "9.0.0";
 
-  src = fetchurl {
+  src = fetchzip {
     url = "https://tetr.io/about/desktop/builds/${lib.versions.major finalAttrs.version}/TETR.IO%20Setup.deb";
-    hash = "sha256-UriLwMB8D+/T32H4rPbkJAy/F/FFhNpd++0AR1lwEfs=";
+    hash = "sha256-TgegFy+sHjv0ILaiLO1ghyUhKXoj8v43ACJOJhKyI0c=";
+    nativeBuildInputs = [ dpkg ];
   };
 
   nativeBuildInputs = [
-    dpkg
-    autoPatchelfHook
-    wrapGAppsHook
+    makeWrapper
   ];
 
-  dontWrapGApps = true;
-
-  buildInputs = [
-    alsa-lib
-    cups
-    libX11
-    libXScrnSaver
-    libXtst
-    mesa
-    nss
-    gtk3
-  ];
+  installPhase =
+    let
+      tetrio-plus' =
+        if tetrio-plus == null
+        then
+          callPackage ./tetrio-plus.nix
+            {
+              tetrio-src = finalAttrs.src;
+              tetrio-version = finalAttrs.version;
+            }
+        else tetrio-plus;
 
-  unpackCmd = "dpkg -x $curSrc src";
+      asarPath =
+        if withTetrioPlus
+        then "${tetrio-plus'}/app.asar"
+        else "opt/TETR.IO/resources/app.asar";
+    in
+    ''
+      runHook preInstall
 
-  installPhase = ''
-    runHook preInstall
+      mkdir -p $out
+      cp -r usr/share/ $out
 
-    mkdir -p $out/bin
-    cp -r opt/ usr/share/ $out
-    ln -s $out/opt/TETR.IO/TETR.IO $out/bin/tetrio
+      mkdir -p $out/share/TETR.IO/
+      cp ${asarPath} $out/share/TETR.IO/app.asar
 
-    substituteInPlace $out/share/applications/TETR.IO.desktop \
-      --replace-fail "Exec=/opt/TETR.IO/TETR.IO" "Exec=$out/bin/tetrio"
+      substituteInPlace $out/share/applications/TETR.IO.desktop \
+        --replace-fail "Exec=/opt/TETR.IO/TETR.IO" "Exec=$out/bin/tetrio"
 
-    runHook postInstall
-  '';
+      runHook postInstall
+    '';
 
   postFixup = ''
-    wrapProgram $out/opt/TETR.IO/TETR.IO \
-      --prefix LD_LIBRARY_PATH : ${libPath}:$out/opt/TETR.IO \
-      ''${gappsWrapperArgs[@]}
+    makeShellWrapper '${lib.getExe electron}' $out/bin/tetrio \
+      --prefix LD_LIBRARY_PATH : ${addOpenGLRunpath.driverLink}/lib \
+      --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
+      --add-flags $out/share/TETR.IO/app.asar
   '';
 
   meta = {
+    changelog = "https://tetr.io/about/desktop/history/";
     description = "TETR.IO desktop client";
     downloadPage = "https://tetr.io/about/desktop/";
     homepage = "https://tetr.io";
@@ -88,7 +74,8 @@ stdenv.mkDerivation (finalAttrs: {
       Play against friends and foes all over the world, or claim a spot on the leaderboards - the stacker future is yours!
     '';
     mainProgram = "tetrio";
-    maintainers = with lib.maintainers; [ wackbyte ];
+    maintainers = with lib.maintainers; [ wackbyte huantian ];
     platforms = [ "x86_64-linux" ];
+    sourceProvenance = [ lib.sourceTypes.binaryBytecode ];
   };
-}))
+})