Package the headless T3 Code server CLI (t3) in the flake
nixpkgs has no t3code package and the npm `t3` package is only a downloader, so fetch the official GitHub release tarball for v0.1.12-nightly.20261123.5165 (4 commits ahead of the vendor pin) and wrap it as packages.t3 / a devShell binary. The Node SEA binary is left unstripped and unpatched (patchelf/strip corrupt its embedded resource); only native .node modules get an rpath to nix libraries. Verified: `t3 serve` runs headless and writes the server-runtime.json that t3tui discovers. `t3 --version` and `t3 serve --help` work through `nix develop`. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
1 parent
b40f09e56f
commit
6a7b9d26a0
3 files changed
+73
-2
No files matched your search
@@ -80,6 +80,8 @@ See [docs/reference.md](docs/reference.md) for every key, the message box, diffs
|
|||||||
|
|
||||||
t3tui finds the local T3 Code server from `~/.t3/userdata/server-runtime.json` (override with `T3TUI_SERVER`). On first run it issues itself a session with `t3 auth session issue --label t3tui`, scoped to what it needs, and stores it in `~/.config/t3tui/credentials.json`. Revoke it any time with `t3 auth session revoke`. For a remote server, pass a token in `T3TUI_TOKEN`.
|
t3tui finds the local T3 Code server from `~/.t3/userdata/server-runtime.json` (override with `T3TUI_SERVER`). On first run it issues itself a session with `t3 auth session issue --label t3tui`, scoped to what it needs, and stores it in `~/.config/t3tui/credentials.json`. Revoke it any time with `t3 auth session revoke`. For a remote server, pass a token in `T3TUI_TOKEN`.
|
||||||
|
|
||||||
|
No desktop app needed: the flake in this repo also packages the headless server CLI, so `nix develop --command t3 serve` (or `nix build .#t3` and run `result/bin/t3 serve`) starts T3 Code with no browser — it writes the same `server-runtime.json` that t3tui reads.
|
||||||
|
|
||||||
The scopes, the protocol and how to update for a newer T3 Code are in [docs/development.md](docs/development.md).
|
The scopes, the protocol and how to update for a newer T3 Code are in [docs/development.md](docs/development.md).
|
||||||
|
|
||||||
## Not yet supported
|
## Not yet supported
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
description = "t3tui local development dependencies (bun)";
|
description = "t3tui local development dependencies (bun) and the headless T3 Code server (t3)";
|
||||||
|
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
|
|
||||||
@@ -9,16 +9,84 @@
|
|||||||
systems = [
|
systems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
"x86_64-darwin"
|
|
||||||
"aarch64-darwin"
|
"aarch64-darwin"
|
||||||
];
|
];
|
||||||
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f (import nixpkgs { inherit system; }));
|
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f (import nixpkgs { inherit system; }));
|
||||||
|
|
||||||
|
# Headless T3 Code server CLI (`t3 serve` runs the server with no browser/desktop app).
|
||||||
|
# nixpkgs has no t3code package (its `t3` is an unrelated tool) and the npm `t3`
|
||||||
|
# package is only a downloader, so fetch the official GitHub release tarball directly.
|
||||||
|
# This nightly is 4 commits ahead of the vendor/t3code pin (42c9107983), the closest
|
||||||
|
# published build; bump it when the submodule is bumped.
|
||||||
|
t3Version = "0.1.12-nightly.20261123.5165";
|
||||||
|
t3Assets = {
|
||||||
|
"x86_64-linux" = {
|
||||||
|
platform = "linux-x64";
|
||||||
|
sha256 = "3178eb07779704301177d54df0d5aaf3504ffcfd19d1a2cc4ce23d5f4cd0b073";
|
||||||
|
};
|
||||||
|
"aarch64-linux" = {
|
||||||
|
platform = "linux-arm64";
|
||||||
|
sha256 = "d29ff33fa72a979f7cf9ed1b30321cf8938fac012223e8dd5fad5e8fe3aab20b";
|
||||||
|
};
|
||||||
|
"aarch64-darwin" = {
|
||||||
|
platform = "darwin-arm64";
|
||||||
|
sha256 = "1c6c9bac20160e83cb7fa15e5dcac1ef4f738ee84583e1afe7b5e5eb724c3485";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
mkT3 =
|
||||||
|
pkgs:
|
||||||
|
let
|
||||||
|
asset =
|
||||||
|
t3Assets.${pkgs.system}
|
||||||
|
or (throw "t3: no release asset for ${pkgs.system} (linux-x64, linux-arm64, darwin-arm64)");
|
||||||
|
src = pkgs.fetchurl {
|
||||||
|
url = "https://github.com/pingdotgg/t3code/releases/download/v${t3Version}/t3-${t3Version}-${asset.platform}.tar.gz";
|
||||||
|
inherit (asset) sha256;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "t3";
|
||||||
|
version = t3Version;
|
||||||
|
inherit src;
|
||||||
|
sourceRoot = "t3-${t3Version}-${asset.platform}";
|
||||||
|
# Stripping or patchelf-ing the Node SEA binary corrupts its embedded resource.
|
||||||
|
dontStrip = true;
|
||||||
|
dontPatchELF = true;
|
||||||
|
# The binary resolves its node_modules/client trees relative to itself, so keep
|
||||||
|
# the whole release directory together under $out/lib and wrap $out/bin/t3.
|
||||||
|
# The main binary is a Node SEA: patchelf corrupts its embedded resource, and it
|
||||||
|
# runs on the host loader (/lib64/ld-linux), so leave the binary itself alone and
|
||||||
|
# only give the native .node modules an rpath to nix libraries.
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
mkdir -p $out/lib $out/bin
|
||||||
|
cp -r . $out/lib/t3
|
||||||
|
${pkgs.lib.optionalString pkgs.stdenv.isLinux ''
|
||||||
|
libPath="${pkgs.lib.makeLibraryPath [
|
||||||
|
pkgs.stdenv.cc.cc.lib
|
||||||
|
pkgs.zlib
|
||||||
|
]}"
|
||||||
|
find $out/lib/t3/node_modules -type f -name '*.node' -print0 |
|
||||||
|
while IFS= read -r -d "" f; do
|
||||||
|
${pkgs.patchelf}/bin/patchelf --set-rpath "$libPath" "$f" || true
|
||||||
|
done
|
||||||
|
''}
|
||||||
|
printf '%s\n' "#!${pkgs.runtimeShell}" "exec $out/lib/t3/t3 \"\$@\"" > $out/bin/t3
|
||||||
|
chmod +x $out/bin/t3
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
packages = forAllSystems (pkgs: {
|
||||||
|
t3 = mkT3 pkgs;
|
||||||
|
});
|
||||||
|
|
||||||
devShells = forAllSystems (pkgs: {
|
devShells = forAllSystems (pkgs: {
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
packages = [
|
packages = [
|
||||||
pkgs.bun
|
pkgs.bun
|
||||||
|
(mkT3 pkgs)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user