Skip to content

t3code: init at 0.0.15#497465

Closed
colonelpanic8 wants to merge 1 commit intoNixOS:masterfrom
colonelpanic8:imalison/t3code-package
Closed

t3code: init at 0.0.15#497465
colonelpanic8 wants to merge 1 commit intoNixOS:masterfrom
colonelpanic8:imalison/t3code-package

Conversation

@colonelpanic8
Copy link
Copy Markdown
Contributor

Summary

  • add a new t3code package for pingdotgg/t3code
  • build the upstream web UI and server from source with Bun
  • install a t3code wrapper and mark imalison as maintainer

Testing

  • nix-build -A t3code
  • ./result/bin/t3code --version
  • timeout 5s ./result/bin/t3code --no-browser --port 48001

@nixpkgs-ci nixpkgs-ci Bot added 8.has: package (new) This PR adds a new package 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 9.needs: reviewer This PR currently has no reviewers requested and needs attention. labels Mar 7, 2026
Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
@nixpkgs-ci nixpkgs-ci Bot removed the 9.needs: reviewer This PR currently has no reviewers requested and needs attention. label Mar 7, 2026
@qweered
Copy link
Copy Markdown
Contributor

qweered commented Mar 7, 2026

Here are some suggested improvements on top of this PR:

  • Version bump to 0.0.4 (tagged release, using tag instead of rev)
  • Desktop app: builds + installs Electron desktop wrapper with Wayland support, .desktop file, and icon
  • Shell completions: bash, zsh, fish via installShellCompletion
  • nix-update-script with --subpackage node_modules
  • Simplified node-pty: glob cd instead of find+if+subshell
  • Simplified install: removed unneeded package.json copies (all @t3tools/* packages are inlined by tsdown), uses --no-preserve=mode + find -xtype l -delete for broken workspace symlinks
  • Cleanup: removed impureEnvVars (already covered by writableTmpDirAsHomeHook), redundant export HOME/BUN_INSTALL_CACHE_DIR, nodejs_24nodejs, dropped restrictive platforms/sourceProvenance
Patch (applies on top of current PR)
--- a/pkgs/by-name/t3/t3code/package.nix
+++ b/pkgs/by-name/t3/t3code/package.nix
@@ -2,12 +2,17 @@
   lib,
   stdenv,
   bun,
+  copyDesktopItems,
+  electron,
   fetchFromGitHub,
+  installShellFiles,
+  makeDesktopItem,
   makeBinaryWrapper,
   node-gyp,
-  nodejs_24,
+  nodejs,
   python3,
   writableTmpDirAsHomeHook,
+  nix-update-script,
 }:
 
 stdenv.mkDerivation (finalAttrs: {
@@ -14,5 +19,5 @@
   pname = "t3code";
-  version = "0.0.3-unstable-2026-03-06";
+  version = "0.0.4";
 
   src = fetchFromGitHub {
     owner = "pingdotgg";
@@ -19,6 +24,6 @@
     repo = "t3code";
-    rev = "5a90b6be9c902df934bada91b543865c197cfb2d";
-    hash = "sha256-lUXScjYjlBgg4GHLs7Z2L2niQsFlkwsdklxQpQV0Wkw=";
+    tag = "v\${finalAttrs.version}";
+    hash = "sha256-66qxVToZxH6AUDWUkA7OCJkrlEe3eBIX1jHghGT1/T0=";
   };
 
   node_modules = stdenv.mkDerivation {
@@ -25,14 +30,9 @@
     pname = "\${finalAttrs.pname}-node_modules";
     inherit (finalAttrs) src version;
 
-    impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
-      "GIT_PROXY_COMMAND"
-      "SOCKS_SERVER"
-    ];
-
     nativeBuildInputs = [
       bun
-      nodejs_24
+      nodejs
       writableTmpDirAsHomeHook
     ];
 
@@ -42,9 +42,6 @@
     buildPhase = ''
       runHook preBuild
 
-      export HOME=\$(mktemp -d)
-      export BUN_INSTALL_CACHE_DIR=\$(mktemp -d)
-
       for packageJson in \
         apps/server/package.json \
         apps/web/package.json \
@@ -61,6 +58,7 @@
         --frozen-lockfile \
         --filter ./apps/server \
         --filter ./apps/web \
+        --filter ./apps/desktop \
         --filter ./packages/contracts \
         --filter ./packages/shared
 
@@ -76,7 +74,7 @@
       runHook postInstall
     '';
 
-    outputHash = "sha256-ImZNhJhS4dMLLT+TV3+BezrTI8rWBRfiK6GoD9kW1Ys=";
+    outputHash = "sha256-nJUgJoT2HNSjzzUDZ2aRhTJFcfTDQvuoQ4F42Fz+/90=";
     outputHashAlgo = "sha256";
     outputHashMode = "recursive";
   };
@@ -83,9 +81,11 @@
 
   nativeBuildInputs = [
     bun
+    copyDesktopItems
+    installShellFiles
     makeBinaryWrapper
     node-gyp
-    nodejs_24
+    nodejs
     python3
     writableTmpDirAsHomeHook
   ];
@@ -98,22 +98,12 @@
     chmod -R u+rwX node_modules
     patchShebangs node_modules
 
-    export HOME=\$(mktemp -d)
-    export PATH="\$PWD/node_modules/.bin:\$PATH"
-    export npm_config_nodedir=\${nodejs_24}
+    # Compile node-pty native addon (no linux prebuild shipped)
+    cd node_modules/.bun/node-pty@*/node_modules/node-pty
+    node-gyp rebuild
+    node scripts/post-install.js
+    cd "\$NIX_BUILD_TOP/\$sourceRoot"
 
-    nodePtyDir="\$(find node_modules/.bun -maxdepth 1 -type d -name 'node-pty@*' | head -n 1)"
-    if [ -z "\$nodePtyDir" ]; then
-      echo "Could not locate node-pty in node_modules/.bun" >&2
-      exit 1
-    fi
-
-    (
-      cd "\$nodePtyDir/node_modules/node-pty"
-      node-gyp rebuild
-      node scripts/post-install.js
-    )
-
     runHook postConfigure
   '';
 
@@ -122,6 +112,7 @@
 
     bun run --cwd apps/web build
     bun run --cwd apps/server build
+    bun run --cwd apps/desktop build
 
     runHook postBuild
   '';
@@ -129,22 +120,25 @@
   installPhase = ''
     runHook preInstall
 
-    mkdir -p \
-      \$out/bin \
-      \$out/libexec/t3code/apps/server \
-      \$out/libexec/t3code/apps/web \
-      \$out/libexec/t3code/packages/shared \
-      \$out/libexec/t3code/packages/contracts
-    cp -R node_modules \$out/libexec/t3code/
-    cp -R apps/server/node_modules \$out/libexec/t3code/apps/server/
-    cp -R apps/server/dist \$out/libexec/t3code/apps/server/
-    install -Dm644 apps/web/package.json \$out/libexec/t3code/apps/web/package.json
-    install -Dm644 packages/shared/package.json \$out/libexec/t3code/packages/shared/package.json
-    install -Dm644 packages/contracts/package.json \$out/libexec/t3code/packages/contracts/package.json
+    mkdir -p \$out/libexec/t3code/apps/{server,desktop}
+    cp -R --no-preserve=mode node_modules \$out/libexec/t3code/
+    cp -R --no-preserve=mode apps/server/{node_modules,dist} \$out/libexec/t3code/apps/server/
+    cp -R --no-preserve=mode apps/desktop/{node_modules,dist-electron} \$out/libexec/t3code/apps/desktop/
 
-    makeWrapper \${lib.getExe nodejs_24} \$out/bin/t3code \
-      --add-flags "\$out/libexec/t3code/apps/server/dist/index.mjs"
+    # Remove broken @t3tools workspace symlinks (inlined by tsdown at build time)
+    find \$out/libexec/t3code -xtype l -delete
+
+    # Server wrapper
+    makeWrapper \${lib.getExe nodejs} \$out/bin/t3code \
+      --add-flags "\$out/libexec/t3code/apps/server/dist/index.mjs"
+
+    # Desktop wrapper
+    makeWrapper \${lib.getExe electron} \$out/bin/t3code-desktop \
+      --add-flags "\$out/libexec/t3code/apps/desktop/dist-electron/main.js" \
+      --add-flags "\\'\\'\\'\${NIXOS_OZONE_WL:+\\'\\'\\'\${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}"
+
+    install -Dm644 assets/prod/black-universal-1024.png \$out/share/icons/hicolor/1024x1024/apps/t3code.png
 
     runHook postInstall
   '';
 
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
+    installShellCompletion --cmd t3code \
+      --bash <(\$out/bin/t3code --completions bash) \
+      --zsh <(\$out/bin/t3code --completions zsh) \
+      --fish <(\$out/bin/t3code --completions fish)
+  '';
+
+  desktopItems = [
+    (makeDesktopItem {
+      name = "t3code";
+      desktopName = "T3 Code";
+      comment = finalAttrs.meta.description;
+      exec = "t3code-desktop %U";
+      terminal = false;
+      icon = "t3code";
+      startupWMClass = "t3code";
+      categories = [
+        "Development"
+        "Utility"
+      ];
+    })
+  ];
+
+  passthru.updateScript = nix-update-script {
+    extraArgs = [
+      "--subpackage"
+      "node_modules"
+    ];
+  };
+
   meta = {
     description = "Minimal web GUI for coding agents";
     homepage = "https://github.com/pingdotgg/t3code";
     license = lib.licenses.mit;
-    maintainers = with lib.maintainers; [ imalison ];
+    maintainers = with lib.maintainers; [
+      imalison
+      qweered
+    ];
     mainProgram = "t3code";
-    platforms = lib.platforms.linux;
-    sourceProvenance = with lib.sourceTypes; [ fromSource ];
   };
 })

@qweered
Copy link
Copy Markdown
Contributor

qweered commented Mar 7, 2026

Optional: closure size reduction (~500MB savings)

The current package ships all 583 .bun/ store entries at runtime (609MB), but only ~113 are actually needed. The server dist externals are effect, @effect/platform-node, @pierre/diffs, ws, node-pty, open; desktop needs effect, electron-updater. Everything else (rolldown 120MB, lucide-react 45MB, typescript 23MB, esbuild, vite, playwright, etc.) is build-only.

The patch prunes unreferenced .bun/ packages by iteratively following symlinks from the runtime deps through their transitive dependencies, then deleting the rest. It also strips node-pty build artifacts (prebuilds, source headers -- 58MB).

Results (tested on v0.0.4):

.bun/ store packages closure
Before 609MB 583 1.9GB
After 101MB 113 1.4GB

The runtime dep list would need updating if new external dependencies are added to the server/desktop tsdown configs.

Patch (applies on top of current PR HEAD)
--- a/pkgs/by-name/t3/t3code/package.nix
+++ b/pkgs/by-name/t3/t3code/package.nix
@@ -2,12 +2,17 @@
   lib,
   stdenv,
   bun,
+  copyDesktopItems,
+  electron,
   fetchFromGitHub,
+  installShellFiles,
+  makeDesktopItem,
   makeBinaryWrapper,
   node-gyp,
-  nodejs_24,
+  nodejs,
   python3,
   writableTmpDirAsHomeHook,
+  nix-update-script,
 }:

 stdenv.mkDerivation (finalAttrs: {
@@ -14,5 +19,5 @@
   pname = "t3code";
-  version = "0.0.3-unstable-2026-03-06";
+  version = "0.0.4";

   src = fetchFromGitHub {
     owner = "pingdotgg";
@@ -19,6 +24,6 @@
     repo = "t3code";
-    rev = "5a90b6be9c902df934bada91b543865c197cfb2d";
-    hash = "sha256-lUXScjYjlBgg4GHLs7Z2L2niQsFlkwsdklxQpQV0Wkw=";
+    tag = "v${finalAttrs.version}";
+    hash = "sha256-66qxVToZxH6AUDWUkA7OCJkrlEe3eBIX1jHghGT1/T0=";
   };

   node_modules = stdenv.mkDerivation {
@@ -25,14 +30,9 @@
     pname = "${finalAttrs.pname}-node_modules";
     inherit (finalAttrs) src version;

-    impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
-      "GIT_PROXY_COMMAND"
-      "SOCKS_SERVER"
-    ];
-
     nativeBuildInputs = [
       bun
-      nodejs_24
+      nodejs
       writableTmpDirAsHomeHook
     ];

@@ -42,9 +42,6 @@
     buildPhase = ''
       runHook preBuild

-      export HOME=$(mktemp -d)
-      export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
-
       for packageJson in \
         apps/server/package.json \
         apps/web/package.json \
@@ -61,6 +58,7 @@
         --frozen-lockfile \
         --filter ./apps/server \
         --filter ./apps/web \
+        --filter ./apps/desktop \
         --filter ./packages/contracts \
         --filter ./packages/shared

@@ -76,7 +74,7 @@
       runHook postInstall
     '';

-    outputHash = "sha256-ImZNhJhS4dMLLT+TV3+BezrTI8rWBRfiK6GoD9kW1Ys=";
+    outputHash = "sha256-nJUgJoT2HNSjzzUDZ2aRhTJFcfTDQvuoQ4F42Fz+/90=";
     outputHashAlgo = "sha256";
     outputHashMode = "recursive";
   };
@@ -83,9 +81,11 @@

   nativeBuildInputs = [
     bun
+    copyDesktopItems
+    installShellFiles
     makeBinaryWrapper
     node-gyp
-    nodejs_24
+    nodejs
     python3
     writableTmpDirAsHomeHook
   ];
@@ -98,22 +98,12 @@
     chmod -R u+rwX node_modules
     patchShebangs node_modules

-    export HOME=$(mktemp -d)
-    export PATH="$PWD/node_modules/.bin:$PATH"
-    export npm_config_nodedir=${nodejs_24}
+    # Compile node-pty native addon (no linux prebuild shipped)
+    cd node_modules/.bun/node-pty@*/node_modules/node-pty
+    node-gyp rebuild
+    node scripts/post-install.js
+    cd "$NIX_BUILD_TOP/$sourceRoot"

-    nodePtyDir="$(find node_modules/.bun -maxdepth 1 -type d -name 'node-pty@*' | head -n 1)"
-    if [ -z "$nodePtyDir" ]; then
-      echo "Could not locate node-pty in node_modules/.bun" >&2
-      exit 1
-    fi
-
-    (
-      cd "$nodePtyDir/node_modules/node-pty"
-      node-gyp rebuild
-      node scripts/post-install.js
-    )
-
     runHook postConfigure
   '';

@@ -122,6 +112,7 @@

     bun run --cwd apps/web build
     bun run --cwd apps/server build
+    bun run --cwd apps/desktop build

     runHook postBuild
   '';
@@ -129,22 +120,76 @@
   installPhase = ''
     runHook preInstall

-    mkdir -p \
-      $out/bin \
-      $out/libexec/t3code/apps/server \
-      $out/libexec/t3code/apps/web \
-      $out/libexec/t3code/packages/shared \
-      $out/libexec/t3code/packages/contracts
-    cp -R node_modules $out/libexec/t3code/
-    cp -R apps/server/node_modules $out/libexec/t3code/apps/server/
-    cp -R apps/server/dist $out/libexec/t3code/apps/server/
-    install -Dm644 apps/web/package.json $out/libexec/t3code/apps/web/package.json
-    install -Dm644 packages/shared/package.json $out/libexec/t3code/packages/shared/package.json
-    install -Dm644 packages/contracts/package.json $out/libexec/t3code/packages/contracts/package.json
+    mkdir -p $out/libexec/t3code/apps/{server,desktop}
+    cp -R --no-preserve=mode node_modules $out/libexec/t3code/
+    cp -R --no-preserve=mode apps/server/{node_modules,dist} $out/libexec/t3code/apps/server/
+    cp -R --no-preserve=mode apps/desktop/{node_modules,dist-electron} $out/libexec/t3code/apps/desktop/

-    makeWrapper ${lib.getExe nodejs_24} $out/bin/t3code \
+    # Prune .bun store to only runtime dependencies
+    (
+      cd $out/libexec/t3code
+      keepList=$(mktemp)
+      workList=$(mktemp)
+
+      # Seed with only runtime-required packages (not devDependencies)
+      for pkg in \
+        effect @effect/platform-node @pierre/diffs ws node-pty open \
+        electron-updater; do
+        for appDir in apps/server/node_modules apps/desktop/node_modules; do
+          if [ -L "$appDir/$pkg" ]; then
+            readlink -f "$appDir/$pkg"
+          fi
+        done
+      done | sed -n 's|.*/node_modules/.bun/\([^/]*\)/.*|\1|p' \
+           | sort -u > "$workList"
+
+      # Iteratively resolve transitive deps
+      while [ -s "$workList" ]; do
+        comm -23 "$workList" "$keepList" > "$workList.new"
+        mv "$workList.new" "$workList"
+        [ -s "$workList" ] || break
+        cat "$workList" >> "$keepList"
+        sort -u -o "$keepList" "$keepList"
+
+        while IFS= read -r pkg; do
+          [ -d "node_modules/.bun/$pkg" ] || continue
+          find "node_modules/.bun/$pkg" -type l -not -path '*/.bin/*' -exec readlink -f {} \;
+        done < "$workList" \
+          | sed -n 's|.*/node_modules/.bun/\([^/]*\)/.*|\1|p' \
+          | sort -u > "$workList.new"
+        mv "$workList.new" "$workList"
+      done
+
+      for dir in node_modules/.bun/*/; do
+        dirName=$(basename "$dir")
+        if ! grep -qxF "$dirName" "$keepList" 2>/dev/null; then
+          rm -rf "$dir"
+        fi
+      done
+
+      rm -f "$keepList" "$workList"
+    )
+
+    # Strip node-pty build artifacts and prebuilds (58MB+ savings)
+    find $out/libexec/t3code -path '*/node-pty/prebuilds' -exec rm -rf {} +
+    find $out/libexec/t3code -path '*/node-pty/deps' -exec rm -rf {} +
+    find $out/libexec/t3code -path '*/node-pty/src' -exec rm -rf {} +
+    find $out/libexec/t3code -path '*/node-pty/third_party' -exec rm -rf {} +
+
+    # Remove broken symlinks (workspace refs inlined by tsdown + pruned deps)
+    find $out/libexec/t3code -xtype l -delete
+
+    # Server wrapper
+    makeWrapper ${lib.getExe nodejs} $out/bin/t3code \
       --add-flags "$out/libexec/t3code/apps/server/dist/index.mjs"

+    # Desktop wrapper
+    makeWrapper ${lib.getExe electron} $out/bin/t3code-desktop \
+      --add-flags "$out/libexec/t3code/apps/desktop/dist-electron/main.js" \
+      --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}"
+
+    install -Dm644 assets/prod/black-universal-1024.png $out/share/icons/hicolor/1024x1024/apps/t3code.png
+
     runHook postInstall
   '';

@@ -151,3 +196,33 @@
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
+    installShellCompletion --cmd t3code \
+      --bash <($out/bin/t3code --completions bash) \
+      --zsh <($out/bin/t3code --completions zsh) \
+      --fish <($out/bin/t3code --completions fish)
+  '';
+
+  desktopItems = [
+    (makeDesktopItem {
+      name = "t3code";
+      desktopName = "T3 Code";
+      comment = finalAttrs.meta.description;
+      exec = "t3code-desktop %U";
+      terminal = false;
+      icon = "t3code";
+      startupWMClass = "t3code";
+      categories = [
+        "Development"
+        "Utility"
+      ];
+    })
+  ];
+
+  passthru.updateScript = nix-update-script {
+    extraArgs = [
+      "--subpackage"
+      "node_modules"
+    ];
+  };
+
   meta = {
     description = "Minimal web GUI for coding agents";
     homepage = "https://github.com/pingdotgg/t3code";
@@ -154,7 +229,8 @@
     license = lib.licenses.mit;
-    maintainers = with lib.maintainers; [ imalison ];
+    maintainers = with lib.maintainers; [
+      imalison
+      qweered
+    ];
     mainProgram = "t3code";
-    platforms = lib.platforms.linux;
-    sourceProvenance = with lib.sourceTypes; [ fromSource ];
   };
 })

Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Comment thread pkgs/by-name/t3/t3code/package.nix
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. labels Mar 8, 2026
Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Copy link
Copy Markdown
Contributor

@yzhou216 yzhou216 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please edit the PR title to match the package version.

Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Copy link
Copy Markdown
Contributor

@qweered qweered left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm otherwise, also please squash commits, and fix pr title

Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
@colonelpanic8 colonelpanic8 changed the title t3code: init at 0.0.3-unstable-2026-03-06 t3code: init at 0.0.4 Mar 8, 2026
@colonelpanic8 colonelpanic8 force-pushed the imalison/t3code-package branch from 92eef9f to 24534c6 Compare March 8, 2026 17:58
@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Mar 8, 2026
@qweered qweered requested a review from SuperSandro2000 March 9, 2026 23:00
@colonelpanic8 colonelpanic8 force-pushed the imalison/t3code-package branch 2 times, most recently from e76c961 to d6459fe Compare March 18, 2026 05:19
@yzhou216

This comment was marked as outdated.

@colonelpanic8 colonelpanic8 changed the title t3code: init at 0.0.4 t3code: init at 0.0.11 Mar 20, 2026
@colonelpanic8 colonelpanic8 force-pushed the imalison/t3code-package branch from d6459fe to cc67fc3 Compare March 20, 2026 19:51
@yzhou216
Copy link
Copy Markdown
Contributor

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 497465
Commit: cc67fc36358ed9059b553a84f9e00d845dfa8a40 (subsequent changes)
Merge: ff89afe7b2e92278f6615e207c4ffca81e40893e

Logs: https://github.com/yzhou216/nixpkgs-review-gha/actions/runs/23365826686


x86_64-linux

⏩ 1 package marked as broken and skipped:
  • t3code

aarch64-linux

⏩ 1 package marked as broken and skipped:
  • t3code

x86_64-darwin (sandbox = true)

⏩ 1 package marked as broken and skipped:
  • t3code

aarch64-darwin (sandbox = true)

⏩ 1 package marked as broken and skipped:
  • t3code

Copy link
Copy Markdown
Contributor

@yzhou216 yzhou216 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved automatically following the successful run of nixpkgs-review.

@nixpkgs-ci nixpkgs-ci Bot removed the 12.approvals: 1 This PR was reviewed and approved by one person. label Mar 20, 2026
@yzhou216

This comment was marked as outdated.

@colonelpanic8 colonelpanic8 force-pushed the imalison/t3code-package branch from de72e41 to 6227ae1 Compare April 3, 2026 04:08
@colonelpanic8
Copy link
Copy Markdown
Contributor Author

Addressed the latest Darwin nixpkgs-review failures in the existing single commit.

Root causes:

  • x86_64-darwin: node-gyp fell over in GYP's Darwin/Xcode detection
  • aarch64-darwin: vite build failed with getaddrinfo ENOTFOUND localhost

Fix in 6227ae18bf07:

  • add Darwin-only xcbuild and cctools.libtool to the build inputs used for the node-pty rebuild
  • patch apps/web/vite.config.ts from host: "localhost" to host: "127.0.0.1" during postPatch to avoid builder-local hostname resolution

Validation:

  • nix build -L .#t3code
  • confirmed the Darwin evaluation now includes xcbuild and cctools in nativeBuildInputs

I force-pushed the amended single-commit branch just now.

@yzhou216

This comment was marked as outdated.

@colonelpanic8
Copy link
Copy Markdown
Contributor Author

Addressed the remaining Darwin nixpkgs-review failure in the existing single commit.

Root cause:

  • Vite 8 resolves config.server.host while preparing client replacements during vite build
  • with server.host unset, that path falls back to a DNS lookup for localhost
  • on the Darwin sandbox that lookup was failing with getaddrinfo ENOTFOUND localhost
  • patching only server.hmr.host was too narrow; the failing lookup happens earlier from config.server.host

Fix:

  • patch apps/web/vite.config.ts in postPatch to set server.host = "127.0.0.1"
  • keep the earlier host: "localhost" -> "127.0.0.1" substitution for the HMR block as well

Validation:

  • nix build -L .#t3code
  • nix build --dry-run --system x86_64-darwin .#t3code
  • nix build --dry-run --system aarch64-darwin .#t3code

@colonelpanic8 colonelpanic8 force-pushed the imalison/t3code-package branch from 6227ae1 to 47975cc Compare April 3, 2026 04:35
@yzhou216
Copy link
Copy Markdown
Contributor

yzhou216 commented Apr 3, 2026

@colonelpanic8
I hate to say this. Could you please actually test out your fixes instead of giving the obvious LLM generated solutions and responses? I'm afraid that I'm sending reviews to a bot instead of a real human.

@colonelpanic8
Copy link
Copy Markdown
Contributor Author

@colonelpanic8 I hate to say this. Could you please actually test out your fixes instead of giving the obvious LLM generated solutions and responses? I'm afraid that I'm sending reviews to a bot instead of a real human.

is there anything outstanding? I literally can't do anything to test on darwin because i dont have a mac...

@yzhou216
Copy link
Copy Markdown
Contributor

yzhou216 commented Apr 3, 2026

I literally can't do anything to test on darwin because i dont have a mac...

The least you can try is to cross compile for Darwin or run OS X in QEMU.

@colonelpanic8
Copy link
Copy Markdown
Contributor Author

I did an actual Darwin cross-compilation attempt from Linux instead of another dry-run-only check.

What I tried:

  • nix build -L --impure --expr 'let pkgs = import /home/imalison/Projects/nixpkgs/.worktrees/pr-497465 { localSystem = "x86_64-linux"; crossSystem = "x86_64-darwin"; }; in pkgs.t3code'
  • NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix build -L --impure --expr 'let pkgs = import /home/imalison/Projects/nixpkgs/.worktrees/pr-497465 { localSystem = "x86_64-linux"; crossSystem = "x86_64-darwin"; }; in pkgs.t3code'
  • same again for aarch64-darwin

What I changed in the package while doing that:

  • switched build-time tools to buildPackages.* in nativeBuildInputs
  • gated installCheck on stdenv.buildPlatform.canExecute stdenv.hostPlatform
  • set npm_config_nodedir=${nodejs} before the node-gyp rebuild

Validation on the native path still passes:

  • nix build -L .#t3code

Cross-compilation result:

  • without NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1, Darwin-only pieces in the target toolchain are rejected by the unsupported-system guard
  • with that override, the package gets past that guard, but both x86_64-darwin and aarch64-darwin then stop in evaluation with an infinite recursion encountered error when the derivation needs target nodejs / electron out paths
  • I reproduced that separately with builtins.toString pkgs.nodejs and builtins.toString pkgs.electron_40 in the same cross package set

So I did perform the requested cross-compilation attempt, but the current blocker is lower in the Darwin target nodejs / electron stack rather than the earlier t3code-specific fixes.

@colonelpanic8 colonelpanic8 force-pushed the imalison/t3code-package branch from 47975cc to 2495b10 Compare April 3, 2026 06:01
@colonelpanic8
Copy link
Copy Markdown
Contributor Author

Correction on the Darwin cross-compilation debugging: the recursion is broader than t3code.

After rerunning with NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1, I can reproduce the same infinite recursion encountered failure with a trivial package too:

  • NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-instantiate --eval --strict --show-trace --impure --expr 'let pkgs = import /home/imalison/Projects/nixpkgs/.worktrees/pr-497465 { localSystem = "x86_64-linux"; crossSystem = "x86_64-darwin"; }; in builtins.toString pkgs.hello'

That fails in the Darwin cross stack at:

  • pkgs/by-name/ap/apple-sdk/common/propagate-inputs.nix:65

So with unsupported systems allowed, this machine can in fact be used to debug further, but the current blocker is a more general Darwin cross recursion in the package set rather than something specific to t3code.

I’m keeping the t3code host/build cleanup I pushed because it is still the correct split for native vs cross build tools and it does not break the native Linux build (nix build -L .#t3code still passes).

@yzhou216
Copy link
Copy Markdown
Contributor

yzhou216 commented Apr 3, 2026

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 497465
Commit: 47975ccceeca91972439a9e42b7923b1b88f7246 (subsequent changes)
Merge: 60ed85e16fbcb11abc2e7bfdf50062c714766dc4

Logs: https://github.com/yzhou216/nixpkgs-review-gha/actions/runs/23934694536

Download packages from cache:
  • x86_64-linux
    nix-store -r --add-root nixpkgs-pr-497465-x86_64-linux \
      --option binary-caches 'https://cache.nixos.org/ https://yzhou216.cachix.org' \
      --option trusted-public-keys '
      cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
      yzhou216.cachix.org-1:O7nGwQnLGGBGE8zYFMipVzPVN956FcV57y9SqwEP+O8=
      ' \
      /nix/store/9pdk8rswfj3b1bxbpa2xvw06jf18qm36-t3code-0.0.15
  • aarch64-linux
    nix-store -r --add-root nixpkgs-pr-497465-aarch64-linux \
      --option binary-caches 'https://cache.nixos.org/ https://yzhou216.cachix.org' \
      --option trusted-public-keys '
      cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
      yzhou216.cachix.org-1:O7nGwQnLGGBGE8zYFMipVzPVN956FcV57y9SqwEP+O8=
      ' \
      /nix/store/nlb93mdiv0i3spr66z67qp3vwvzdcpdc-t3code-0.0.15
  • x86_64-darwin
    nix-store -r --add-root nixpkgs-pr-497465-x86_64-darwin \
      --option binary-caches 'https://cache.nixos.org/ https://yzhou216.cachix.org' \
      --option trusted-public-keys '
      cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
      yzhou216.cachix.org-1:O7nGwQnLGGBGE8zYFMipVzPVN956FcV57y9SqwEP+O8=
      ' \
      /nix/store/i56za31p3x1rivplf1xhwl004ixb98a2-t3code-0.0.15
  • aarch64-darwin
    nix-store -r --add-root nixpkgs-pr-497465-aarch64-darwin \
      --option binary-caches 'https://cache.nixos.org/ https://yzhou216.cachix.org' \
      --option trusted-public-keys '
      cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
      yzhou216.cachix.org-1:O7nGwQnLGGBGE8zYFMipVzPVN956FcV57y9SqwEP+O8=
      ' \
      /nix/store/3pqkxm7pwwzjqdf70k0ywy85w8hiy55p-t3code-0.0.15

x86_64-linux

✅ 1 package built:
  • t3code

aarch64-linux

✅ 1 package built:
  • t3code

x86_64-darwin (sandbox = true)

✅ 1 package built:
  • t3code

aarch64-darwin (sandbox = true)

✅ 1 package built:
  • t3code

Copy link
Copy Markdown
Contributor

@yzhou216 yzhou216 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved automatically following the successful run of nixpkgs-review.

Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Comment thread pkgs/by-name/t3/t3code/package.nix Outdated
Comment thread pkgs/by-name/t3/t3code/package.nix
Copy link
Copy Markdown
Member

@PerchunPak PerchunPak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^^^

@colonelpanic8 colonelpanic8 force-pushed the imalison/t3code-package branch from 2495b10 to ea6246a Compare April 14, 2026 22:48
@colonelpanic8
Copy link
Copy Markdown
Contributor Author

Addressed the April 14 review in the existing single commit and rebased onto current origin/master.

Changes:

  • removed the cross-compilation-specific buildPackages wiring and install-check gating
  • removed the downstream package.json version rewrites and dropped versionCheckHook
  • removed the no-op desktop resource path patch
  • documented the Bun normalization helpers and switched meta.mainProgram to t3code-desktop

Validation:

  • nix build -L .#t3code

One remaining upstream quirk after removing the downstream version rewrites: ./result/bin/t3code --version still reports the upstream embedded CLI version (t3 v0.0.14) until that is fixed upstream.

Current PR head: ea6246af8f4268751fd95621d913e4f58129be4b

bun --bun ${./canonicalize-node-modules.ts}

# Rebuild .bin symlinks against the canonicalized .bun layout so the
# vendored node_modules tree keeps deterministic relative targets.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is water, and it describes absolutely nothing. Please write with your own memory why you added this and what problem it solves. Also, did you at least read what I wrote?

Copy link
Copy Markdown
Contributor Author

@colonelpanic8 colonelpanic8 Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes the hash reliable across platforms in a way it was not before. My original plan was to drop Darwin support, but @yzhou216 asked me to spend significant time trying to make it work, including attempting cross-compilation. Now the suggestion is to drop Darwin support after all.

The level of debate over very minor details on a pull request that has been in good shape for quite a while is exhausting. I am done spending more time on it. If @qweered wants to get it over the line or build their own version, they are welcome to do so.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yzhou216 asked me to spend significant time trying to make it work

Do you mean that the LLM you are using spent a significant time?

No offense, I think people here who have reviewed this PR also spent a significant amount of time. I'm fine with LLM usage, but it's a bit unfair that we are using manpower to review and just getting bot replies from you.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, I am sorry for what I said yesterday. I should not have said that. But I agree with @yzhou216 in some aspect, having LLM respond to someone without any of your actual effort is disrespectful

@yzhou216
Copy link
Copy Markdown
Contributor

@t3dotgg, sorry for the ping. I'm not sure how much you care about Nix, but I'm just wondering if you would like to take a look at this.

@PerchunPak
Copy link
Copy Markdown
Member

Please don't ping a busy man. It puts an unfair burden on the upstream for something that is our (as the Nix community) job. If there is genuine interest in the package, someone will step up and maintain it

@yzhou216
Copy link
Copy Markdown
Contributor

unfair burden

If the upstream is interested, that's great. Otherwise, we don't hear anything back, which is fine too. How would that be a burden?

@iamanaws iamanaws mentioned this pull request Apr 16, 2026
13 tasks
@PerchunPak
Copy link
Copy Markdown
Member

For everyone interested, @iamanaws opened a PR for t3code (thanks!)
#510466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants