Package t3tui itself as a flake output (packages.t3tui / apps.t3tui)
Builds one self-contained binary with `bun build --compile`. npm deps come from a fixed-output derivation (this nixpkgs has no bun fetcher); the vendored t3code submodule is grafted from a pinned flake input (same commit as the submodule) because git flake sources don't include submodule contents. The binary is a Bun SEA, so strip/patchelf are disabled on the package. link-vendor now chmods copied vendor files writable before patching (nix store sources are read-only). Verified: nix build .#t3tui -> bin/t3tui version prints 0.2.0. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
1 parent
9d1f6d8bc9
commit
c5311a763f
3 files changed
+129
-6
No files matched your search
@@ -1,10 +1,19 @@
|
||||
{
|
||||
description = "t3tui local development dependencies (bun) and the headless T3 Code server (t3)";
|
||||
description = "t3tui, a terminal client for T3 Code (packages: t3tui binary, t3 headless server)";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
# The vendored T3 Code contracts/runtime. The git submodule under vendor/t3code is the
|
||||
# source of truth for local development; this input pins the same commit for flake
|
||||
# builds, where git submodule contents are not part of the fetched tree.
|
||||
t3code = {
|
||||
url = "github:pingdotgg/t3code/42c9107983d8f65c38117501cbcde1ee5c82ef14";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ nixpkgs, ... }:
|
||||
{ self, nixpkgs, t3code, ... }:
|
||||
let
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
@@ -76,10 +85,102 @@
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
# t3tui itself, compiled to one self-contained binary with `bun build --compile`.
|
||||
# npm dependencies come from a fixed-output derivation (this nixpkgs has no bun
|
||||
# fetcher), so the real build is offline. The version comes from package.json.
|
||||
mkT3tui =
|
||||
pkgs:
|
||||
let
|
||||
version = (pkgs.lib.importJSON ./package.json).version;
|
||||
compileTarget = {
|
||||
"x86_64-linux" = "linux-x64";
|
||||
"aarch64-linux" = "linux-arm64";
|
||||
"aarch64-darwin" = "darwin-arm64";
|
||||
}.${pkgs.system};
|
||||
# Flake sources from git don't include the submodule's contents, so graft the
|
||||
# pinned t3code input in place of vendor/t3code.
|
||||
src = pkgs.runCommand "t3tui-src-${version}" { } ''
|
||||
cp -r ${./.} "$out"
|
||||
chmod -R u+w "$out"
|
||||
rm -rf "$out/vendor/t3code"
|
||||
# Copied, not symlinked: module resolution must find the project's
|
||||
# node_modules above vendor/, and a symlink would resolve to the store.
|
||||
cp -r ${t3code} "$out/vendor/t3code"
|
||||
'';
|
||||
deps = pkgs.stdenvNoCC.mkDerivation {
|
||||
pname = "t3tui-deps";
|
||||
inherit version src;
|
||||
nativeBuildInputs = [
|
||||
pkgs.bun
|
||||
pkgs.cacert
|
||||
];
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHash = "sha256-aLJSI2zpF2lh4sZwul4xD2edHcWiqq/BxJXLltaE5jE=";
|
||||
dontFixup = true;
|
||||
dontConfigure = true;
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
export HOME=$TMPDIR
|
||||
chmod -R u+w .
|
||||
bun install --frozen-lockfile
|
||||
runHook postBuild
|
||||
'';
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir "$out"
|
||||
cp -r node_modules "$out/node_modules"
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
in
|
||||
pkgs.stdenv.mkDerivation {
|
||||
pname = "t3tui";
|
||||
inherit version src;
|
||||
nativeBuildInputs = [ pkgs.bun ];
|
||||
dontConfigure = true;
|
||||
# The binary is a Bun SEA: stripping or patching its ELF corrupts the embedded app.
|
||||
dontStrip = true;
|
||||
dontPatchELF = true;
|
||||
dontPatchShebangs = true;
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
export HOME=$TMPDIR
|
||||
chmod -R u+w .
|
||||
cp -r ${deps}/node_modules .
|
||||
chmod -R u+w node_modules
|
||||
bun run compile ${compileTarget}
|
||||
runHook postBuild
|
||||
'';
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dm755 "release/t3tui-${compileTarget}" "$out/bin/t3tui"
|
||||
runHook postInstall
|
||||
'';
|
||||
meta = {
|
||||
description = "A terminal client for T3 Code";
|
||||
homepage = "https://git.venomade.com/venomade/t3tui";
|
||||
license = pkgs.lib.licenses.mit;
|
||||
mainProgram = "t3tui";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
packages = forAllSystems (pkgs: {
|
||||
t3 = mkT3 pkgs;
|
||||
t3tui = mkT3tui pkgs;
|
||||
default = mkT3tui pkgs;
|
||||
});
|
||||
|
||||
apps = forAllSystems (pkgs: {
|
||||
t3tui = {
|
||||
type = "app";
|
||||
program = "${self.packages.${pkgs.system}.t3tui}/bin/t3tui";
|
||||
};
|
||||
default = {
|
||||
type = "app";
|
||||
program = "${self.packages.${pkgs.system}.t3tui}/bin/t3tui";
|
||||
};
|
||||
});
|
||||
|
||||
devShells = forAllSystems (pkgs: {
|
||||
|
||||
Reference in new issue
Block a user