From dfb10eff9edbd1c1ed771365463c1ac9875f8fd3 Mon Sep 17 00:00:00 2001 From: huantian Date: Wed, 11 Sep 2024 13:29:17 -0700 Subject: [PATCH 1/6] tetrio-desktop: format with nixfmt --- pkgs/by-name/te/tetrio-desktop/package.nix | 46 +++++++++---------- .../by-name/te/tetrio-desktop/tetrio-plus.nix | 41 ++++++++++------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/pkgs/by-name/te/tetrio-desktop/package.nix b/pkgs/by-name/te/tetrio-desktop/package.nix index 56e2f60acc86..a4e2e56a3e60 100644 --- a/pkgs/by-name/te/tetrio-desktop/package.nix +++ b/pkgs/by-name/te/tetrio-desktop/package.nix @@ -1,13 +1,14 @@ -{ stdenv -, lib -, fetchzip -, dpkg -, makeWrapper -, callPackage -, addDriverRunpath -, electron -, withTetrioPlus ? false -, tetrio-plus ? null +{ + stdenv, + lib, + fetchzip, + dpkg, + makeWrapper, + callPackage, + addDriverRunpath, + electron, + withTetrioPlus ? false, + tetrio-plus ? null, }: stdenv.mkDerivation (finalAttrs: { @@ -27,19 +28,15 @@ stdenv.mkDerivation (finalAttrs: { installPhase = let tetrio-plus' = - if tetrio-plus == null - then - callPackage ./tetrio-plus.nix - { - tetrio-src = finalAttrs.src; - tetrio-version = finalAttrs.version; - } - else tetrio-plus; + if tetrio-plus == null then + callPackage ./tetrio-plus.nix { + tetrio-src = finalAttrs.src; + tetrio-version = finalAttrs.version; + } + else + tetrio-plus; - asarPath = - if withTetrioPlus - then "${tetrio-plus'}/app.asar" - else "opt/TETR.IO/resources/app.asar"; + asarPath = if withTetrioPlus then "${tetrio-plus'}/app.asar" else "opt/TETR.IO/resources/app.asar"; in '' runHook preInstall @@ -74,7 +71,10 @@ 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 huantian ]; + maintainers = with lib.maintainers; [ + wackbyte + huantian + ]; platforms = [ "x86_64-linux" ]; sourceProvenance = [ lib.sourceTypes.binaryBytecode ]; }; diff --git a/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix b/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix index 9c12dd1b9a45..ee444b965f4e 100644 --- a/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix +++ b/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix @@ -1,20 +1,21 @@ -{ lib -, stdenv -, fetchFromGitLab -, rustPlatform -, rustc -, wasm-pack -, wasm-bindgen-cli -, binaryen +{ + lib, + stdenv, + fetchFromGitLab, + rustPlatform, + rustc, + wasm-pack, + wasm-bindgen-cli, + binaryen, -, fetchYarnDeps -, yarn -, fixup-yarn-lock -, nodejs -, asar + fetchYarnDeps, + yarn, + fixup-yarn-lock, + nodejs, + asar, -, tetrio-src -, tetrio-version + tetrio-src, + tetrio-version, }: let @@ -76,7 +77,10 @@ let description = "Self contained toolkit for creating, editing, and previewing TPSE files"; homepage = "https://gitlab.com/UniQMG/tpsecore"; license = lib.licenses.mit; - maintainers = with lib.maintainers; [ huantian wackbyte ]; + maintainers = with lib.maintainers; [ + huantian + wackbyte + ]; platforms = lib.platforms.linux; }; }; @@ -160,7 +164,10 @@ stdenv.mkDerivation (finalAttrs: { # is a modified version of tetrio-desktop, which is unfree. lib.licenses.unfree ]; - maintainers = with lib.maintainers; [ huantian wackbyte ]; + maintainers = with lib.maintainers; [ + huantian + wackbyte + ]; platforms = lib.platforms.linux; }; }) From ab8f659d2530a9673cf333eac926ee7c4357b3a5 Mon Sep 17 00:00:00 2001 From: huantian Date: Tue, 1 Oct 2024 11:44:43 -0700 Subject: [PATCH 2/6] tetrio-plus: split into seperate derivation --- pkgs/by-name/te/tetrio-desktop/package.nix | 14 ++------------ .../tetrio-plus.nix => tetrio-plus/package.nix} | 10 ++++------ 2 files changed, 6 insertions(+), 18 deletions(-) rename pkgs/by-name/te/{tetrio-desktop/tetrio-plus.nix => tetrio-plus/package.nix} (95%) diff --git a/pkgs/by-name/te/tetrio-desktop/package.nix b/pkgs/by-name/te/tetrio-desktop/package.nix index a4e2e56a3e60..dd8d76035c52 100644 --- a/pkgs/by-name/te/tetrio-desktop/package.nix +++ b/pkgs/by-name/te/tetrio-desktop/package.nix @@ -4,11 +4,10 @@ fetchzip, dpkg, makeWrapper, - callPackage, addDriverRunpath, electron, withTetrioPlus ? false, - tetrio-plus ? null, + tetrio-plus, }: stdenv.mkDerivation (finalAttrs: { @@ -27,16 +26,7 @@ stdenv.mkDerivation (finalAttrs: { installPhase = let - tetrio-plus' = - if tetrio-plus == null then - callPackage ./tetrio-plus.nix { - tetrio-src = finalAttrs.src; - tetrio-version = finalAttrs.version; - } - else - tetrio-plus; - - asarPath = if withTetrioPlus then "${tetrio-plus'}/app.asar" else "opt/TETR.IO/resources/app.asar"; + asarPath = if withTetrioPlus then tetrio-plus else "opt/TETR.IO/resources/app.asar"; in '' runHook preInstall diff --git a/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix b/pkgs/by-name/te/tetrio-plus/package.nix similarity index 95% rename from pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix rename to pkgs/by-name/te/tetrio-plus/package.nix index ee444b965f4e..9533b656d379 100644 --- a/pkgs/by-name/te/tetrio-desktop/tetrio-plus.nix +++ b/pkgs/by-name/te/tetrio-plus/package.nix @@ -14,8 +14,7 @@ nodejs, asar, - tetrio-src, - tetrio-version, + tetrio-desktop, }: let @@ -107,7 +106,7 @@ stdenv.mkDerivation (finalAttrs: { # 'out' is the directory that the tetrio-plus expects the vanilla asar to be # and this is the directory that will contain the final result that we want - asar extract ${tetrio-src}/opt/TETR.IO/resources/app.asar out + asar extract ${tetrio-desktop.src}/opt/TETR.IO/resources/app.asar out cd out # Install custom package.json/yarn.lock that describe the additional node @@ -125,7 +124,7 @@ stdenv.mkDerivation (finalAttrs: { # The simple build script expects the vanilla asar located here # This patches the vanilla code to load the tetrio-plus code - ln -s ${tetrio-src}/opt/TETR.IO/resources/app.asar app.asar + ln -s ${tetrio-desktop.src}/opt/TETR.IO/resources/app.asar app.asar node ./scripts/build-electron.js # Finally, we install the tetrio-plus code where the above patch script expects @@ -148,8 +147,7 @@ stdenv.mkDerivation (finalAttrs: { installPhase = '' runHook preinstall - mkdir -p $out - asar pack out $out/app.asar + asar pack out $out runHook postinstall ''; From 3bb53bf50098ef76f22a88d1b650c041fc026949 Mon Sep 17 00:00:00 2001 From: huantian Date: Tue, 1 Oct 2024 11:44:57 -0700 Subject: [PATCH 3/6] tetrio-desktop,tetrio-plus: update meta --- pkgs/by-name/te/tetrio-desktop/package.nix | 6 +++--- pkgs/by-name/te/tetrio-plus/package.nix | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkgs/by-name/te/tetrio-desktop/package.nix b/pkgs/by-name/te/tetrio-desktop/package.nix index dd8d76035c52..730e8218e2a1 100644 --- a/pkgs/by-name/te/tetrio-desktop/package.nix +++ b/pkgs/by-name/te/tetrio-desktop/package.nix @@ -52,13 +52,13 @@ stdenv.mkDerivation (finalAttrs: { meta = { changelog = "https://tetr.io/about/desktop/history/"; - description = "TETR.IO desktop client"; + description = "Desktop client for TETR.IO, an online stacker game"; downloadPage = "https://tetr.io/about/desktop/"; homepage = "https://tetr.io"; license = lib.licenses.unfree; longDescription = '' - TETR.IO is a modern yet familiar online stacker. - Play against friends and foes all over the world, or claim a spot on the leaderboards - the stacker future is yours! + TETR.IO is a free-to-win modern yet familiar online stacker. + Play multiplayer games 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; [ diff --git a/pkgs/by-name/te/tetrio-plus/package.nix b/pkgs/by-name/te/tetrio-plus/package.nix index 9533b656d379..4accc5209d56 100644 --- a/pkgs/by-name/te/tetrio-plus/package.nix +++ b/pkgs/by-name/te/tetrio-plus/package.nix @@ -19,11 +19,12 @@ let version = "0.27.2"; + rev = "electron-v${version}-tetrio-v${lib.versions.major tetrio-desktop.version}"; src = fetchFromGitLab { owner = "UniQMG"; repo = "tetrio-plus"; - rev = "electron-v${version}-tetrio-v${lib.versions.major tetrio-version}"; + inherit rev; hash = "sha256-PvTivTt1Zuvk5gaCcQDcIBFsUf/ZG7TJYXqm0NP++Bw="; fetchSubmodules = true; @@ -153,9 +154,13 @@ stdenv.mkDerivation (finalAttrs: { ''; meta = { - description = "TETR.IO customization tool suite"; - downloadPage = "https://gitlab.com/UniQMG/tetrio-plus/-/releases"; + description = "Modified TETR.IO desktop app.asar with many customization tools"; + longDescription = '' + To use this, `override` the `withTetrioPlus` attribute of `tetrio-desktop`. + ''; homepage = "https://gitlab.com/UniQMG/tetrio-plus"; + downloadPage = "https://gitlab.com/UniQMG/tetrio-plus/-/releases"; + changelog = "https://gitlab.com/UniQMG/tetrio-plus/-/releases/${rev}"; license = [ lib.licenses.mit # while tetrio-plus is itself mit, the result of this derivation From 46251f6caa9700fb32b9bb3e1065433b16fe27e2 Mon Sep 17 00:00:00 2001 From: huantian Date: Wed, 11 Sep 2024 14:19:15 -0700 Subject: [PATCH 4/6] tetrio-desktop: add --enable-wayland-ime --- pkgs/by-name/te/tetrio-desktop/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/te/tetrio-desktop/package.nix b/pkgs/by-name/te/tetrio-desktop/package.nix index 730e8218e2a1..d5c430774b49 100644 --- a/pkgs/by-name/te/tetrio-desktop/package.nix +++ b/pkgs/by-name/te/tetrio-desktop/package.nix @@ -46,7 +46,7 @@ stdenv.mkDerivation (finalAttrs: { postFixup = '' makeShellWrapper '${lib.getExe electron}' $out/bin/tetrio \ --prefix LD_LIBRARY_PATH : ${addDriverRunpath.driverLink}/lib \ - --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime}}" \ --add-flags $out/share/TETR.IO/app.asar ''; From c861dc26f608bf18d6143879d5e3a38b4bf80041 Mon Sep 17 00:00:00 2001 From: huantian Date: Wed, 11 Sep 2024 16:44:26 -0700 Subject: [PATCH 5/6] tetrio-desktop: switch version to single integer to match upstream Upstream brands each version as "v9" or "Version 9" for example, and tools like TETR.IO PLUS also use only the major version. --- pkgs/by-name/te/tetrio-desktop/package.nix | 4 ++-- pkgs/by-name/te/tetrio-plus/package.nix | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/te/tetrio-desktop/package.nix b/pkgs/by-name/te/tetrio-desktop/package.nix index d5c430774b49..e42eed4589c1 100644 --- a/pkgs/by-name/te/tetrio-desktop/package.nix +++ b/pkgs/by-name/te/tetrio-desktop/package.nix @@ -12,10 +12,10 @@ stdenv.mkDerivation (finalAttrs: { pname = "tetrio-desktop"; - version = "9.0.0"; + version = "9"; src = fetchzip { - url = "https://tetr.io/about/desktop/builds/${lib.versions.major finalAttrs.version}/TETR.IO%20Setup.deb"; + url = "https://tetr.io/about/desktop/builds/${finalAttrs.version}/TETR.IO%20Setup.deb"; hash = "sha256-TgegFy+sHjv0ILaiLO1ghyUhKXoj8v43ACJOJhKyI0c="; nativeBuildInputs = [ dpkg ]; }; diff --git a/pkgs/by-name/te/tetrio-plus/package.nix b/pkgs/by-name/te/tetrio-plus/package.nix index 4accc5209d56..2dcda86842ad 100644 --- a/pkgs/by-name/te/tetrio-plus/package.nix +++ b/pkgs/by-name/te/tetrio-plus/package.nix @@ -19,7 +19,7 @@ let version = "0.27.2"; - rev = "electron-v${version}-tetrio-v${lib.versions.major tetrio-desktop.version}"; + rev = "electron-v${version}-tetrio-v${tetrio-desktop.version}"; src = fetchFromGitLab { owner = "UniQMG"; From d7d7797b1325ba7d548f1ec4ffe32e7572a3178d Mon Sep 17 00:00:00 2001 From: huantian Date: Tue, 1 Oct 2024 11:39:57 -0700 Subject: [PATCH 6/6] tetrio-plus: cleanup and reorganize build phase --- pkgs/by-name/te/tetrio-plus/package.nix | 40 ++++++++++--------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/pkgs/by-name/te/tetrio-plus/package.nix b/pkgs/by-name/te/tetrio-plus/package.nix index 2dcda86842ad..460741366612 100644 --- a/pkgs/by-name/te/tetrio-plus/package.nix +++ b/pkgs/by-name/te/tetrio-plus/package.nix @@ -25,21 +25,8 @@ let owner = "UniQMG"; repo = "tetrio-plus"; inherit rev; - hash = "sha256-PvTivTt1Zuvk5gaCcQDcIBFsUf/ZG7TJYXqm0NP++Bw="; + hash = "sha256-pcT8/YsfHeimSkeNziW9ha63hEgCg2vnvJSZAY1c7P0="; fetchSubmodules = true; - - # tetrio-plus uses this info for displaying its version, - # so we need to deep clone to have all the revision history. - # After we're done, we emulate 'leaveDotGit = false' by removing - # all the .git folders. - leaveDotGit = true; - deepClone = true; - postFetch = '' - cd "$out" - git rev-parse --short HEAD~1 > resources/ci-commit-previous - git rev-parse --short HEAD > resources/ci-commit - find "$out" -name .git -print0 | xargs -0 rm -rf - ''; }; wasm-bindgen-82 = wasm-bindgen-cli.override { @@ -105,13 +92,14 @@ stdenv.mkDerivation (finalAttrs: { buildPhase = '' runHook preBuild - # 'out' is the directory that the tetrio-plus expects the vanilla asar to be - # and this is the directory that will contain the final result that we want + # tetrio-plus expects the vanilla asar to be extracted into 'out' and + # 'out' is the directory contianing the final patched asar's contents asar extract ${tetrio-desktop.src}/opt/TETR.IO/resources/app.asar out - cd out # Install custom package.json/yarn.lock that describe the additional node # dependencies that tetrio-plus needs to run, and install them in our output + cd out + cp ../resources/desktop-ci/yarn.lock . patch package.json ../resources/desktop-ci/package.json.diff @@ -123,24 +111,26 @@ stdenv.mkDerivation (finalAttrs: { cd .. - # The simple build script expects the vanilla asar located here + # The included build script expects the vanilla asar located here # This patches the vanilla code to load the tetrio-plus code ln -s ${tetrio-desktop.src}/opt/TETR.IO/resources/app.asar app.asar node ./scripts/build-electron.js - # Finally, we install the tetrio-plus code where the above patch script expects + # Actually install tetrio-plus where the above patch script expects cp -r $src out/tetrioplus chmod -R u+w out/tetrioplus - # Disable the uninstall button in the tetrio-plus popup, - # as it doesn't make sense to mutably uninstall it in a nix package + # Install tpsecore + cp ${tpsecore}/{tpsecore_bg.wasm,tpsecore.js} out/tetrioplus/source/lib/ + # Remove uneeded tpsecore source code + rm -rf out/tetrioplus/tpsecore/ + + # Disable useless uninstall button in the tetrio-plus popup substituteInPlace out/tetrioplus/desktop-manifest.js \ --replace-fail '"show_uninstaller_button": true' '"show_uninstaller_button": false' - # We don't need the tpsecore source code bundled - rm -rf out/tetrioplus/tpsecore/ - # since we install the compiled version here - cp ${tpsecore}/{tpsecore_bg.wasm,tpsecore.js} out/tetrioplus/source/lib/ + # Display 'nixpkgs' next to version in tetrio-plus popup + echo "nixpkgs" > out/tetrioplus/resources/override-commit runHook postBuild '';