tetrio-plus: split into seperate derivation (#341251)

This commit is contained in:
h7x4 2024-10-01 22:30:06 +02:00 committed by GitHub
commit 47c55e6a2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 70 additions and 80 deletions

View File

@ -1,21 +1,21 @@
{ stdenv
, lib
, fetchzip
, dpkg
, makeWrapper
, callPackage
, addDriverRunpath
, electron
, withTetrioPlus ? false
, tetrio-plus ? null
{
stdenv,
lib,
fetchzip,
dpkg,
makeWrapper,
addDriverRunpath,
electron,
withTetrioPlus ? false,
tetrio-plus,
}:
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 ];
};
@ -26,20 +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
@ -59,22 +46,25 @@ 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
'';
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; [ wackbyte huantian ];
maintainers = with lib.maintainers; [
wackbyte
huantian
];
platforms = [ "x86_64-linux" ];
sourceProvenance = [ lib.sourceTypes.binaryBytecode ];
};

View File

@ -1,44 +1,32 @@
{ 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-desktop,
}:
let
version = "0.27.2";
rev = "electron-v${version}-tetrio-v${tetrio-desktop.version}";
src = fetchFromGitLab {
owner = "UniQMG";
repo = "tetrio-plus";
rev = "electron-v${version}-tetrio-v${lib.versions.major tetrio-version}";
hash = "sha256-PvTivTt1Zuvk5gaCcQDcIBFsUf/ZG7TJYXqm0NP++Bw=";
inherit rev;
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 {
@ -76,7 +64,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;
};
};
@ -101,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
asar extract ${tetrio-src}/opt/TETR.IO/resources/app.asar out
cd out
# 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
# 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
@ -119,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-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
# 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
'';
@ -144,23 +138,29 @@ stdenv.mkDerivation (finalAttrs: {
installPhase = ''
runHook preinstall
mkdir -p $out
asar pack out $out/app.asar
asar pack out $out
runHook postinstall
'';
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
# 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;
};
})