1
0

feat: TETR.IO (+ TETR.IO PLUS integration)

This commit does feature a _few_ changes to my general NixOS config
(namely the ideology switch from importing things everywhere to having
my own custom "`mpkgs`").

However most of this effort was all thanks to TETR.IO. The former
maintainer of `pkgs.tetrio-desktop` and `pkgs.tetrio-plus` seems to not
have been playing recently enough to update the packages to v10. Making
them unusuable.

`mpkgs.tetrio.desktop` is a patched `pkgs.tetrio-desktop` that updates
to v10. Alongside this, and a quick discovery that you could make custom
home-manager modules, I took it upon myself to make TETR.IO
configurations (including those of TETR.IO PLUS) fully generated from
Nix.

This effort took way too long, and feels slightly hacky (the way
injecting configurations works is by generating a LevelDB (Chromium
IndexedDB) for the electron instance's Local Storage) and it involves
some custom stuff. (LevelDB deriviation, plus home-manager module for
copying files rather than linking them `home.initialFile`.)

I'm proud of the result, and Tetris is now fully deterministic,
reproducible, and Nix-y.
This commit is contained in:
2026-01-14 21:49:20 +01:00
parent af86c0c1e5
commit 134fe16393
9 changed files with 1157 additions and 16 deletions

30
pkgs/tetrio/default.nix Normal file
View File

@@ -0,0 +1,30 @@
{
pkgs ? import <nixpkgs> { },
fetchzip ? pkgs.fetchzip,
withTetrioPlus ? false,
tetrio-plus ? pkgs.tetrio-plus,
...
}:
let
tetrio-desktop =
let
version = "10";
in
{
inherit version;
src = fetchzip {
url = "https://tetr.io/about/desktop/builds/${version}/TETR.IO%20Setup.deb";
hash = "sha256-2FtFCajNEj7O8DGangDecs2yeKbufYLx1aZb3ShnYvw=";
nativeBuildInputs = with pkgs; [ dpkg ];
};
};
in
(pkgs.tetrio-desktop.overrideAttrs {
version = tetrio-desktop.version;
src = tetrio-desktop.src;
}).override {
inherit withTetrioPlus tetrio-plus;
}

32
pkgs/tetrio/leveldb.nix Normal file
View File

@@ -0,0 +1,32 @@
{
pkgs ? import <nixpkgs> { },
mpkgs ? import /etc/nixos/pkgs/default.nix { },
origin ? "https://tetr.io",
key ? "userConfig",
value,
...
}:
let
src = ./.;
in
pkgs.stdenv.mkDerivation {
pname = "tetrio-leveldb";
version = "1";
inherit src;
nativeBuildInputs = [ mpkgs.leveldb-cli ];
buildPhase = ''
runHook preBuild
${pkgs.lib.getExe mpkgs.leveldb-cli} \
$out \
${pkgs.lib.escapeShellArg origin} \
${pkgs.lib.escapeShellArg key} \
${pkgs.lib.escapeShellArg (builtins.toJSON value)}
runHook postBuild
'';
}

725
pkgs/tetrio/module.nix Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,31 @@
{
pkgs ? import <nixpkgs> { },
...
}:
let
src = pkgs.fetchurl {
url = "https://you.have.fail/tetrioplus/data/tpsefiles/skin/SpooKoArts/simple_connected.zip.tpse";
hash = "sha256-dIrEpEV9Gy2iU6K6rMrNX4XFQEchkJqSmOuQwVF4EQQ=";
};
in
pkgs.stdenv.mkDerivation {
name = "simple-connected";
version = "2022-06-26";
inherit src;
dontUnpack = true;
dontBuild = true;
installPhase = ''
runHook preInstall
cp ${src} $out
runHook postInstall
'';
fixupPhase = ''
runHook preFixup
sed -i 's/\bskin\b/value/' $out
runHook postFixup
'';
}