From d9af9a4312052aa9b64522ff4cab50dede5530cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lima?= Date: Sat, 4 Jul 2026 00:06:12 +0100 Subject: [PATCH] t3code: split into standalone wrapper --- pkgs/by-name/t3/t3code/package.nix | 85 +++++++++++++++++++++++++++- pkgs/by-name/t3/t3code/unwrapped.nix | 54 +++--------------- 2 files changed, 91 insertions(+), 48 deletions(-) diff --git a/pkgs/by-name/t3/t3code/package.nix b/pkgs/by-name/t3/t3code/package.nix index e4079e00f828..6352c9047ff7 100644 --- a/pkgs/by-name/t3/t3code/package.nix +++ b/pkgs/by-name/t3/t3code/package.nix @@ -1 +1,84 @@ -import ./unwrapped.nix +{ + lib, + callPackage, + symlinkJoin, + makeBinaryWrapper, + enableAzureDevOps ? false, + azure-cli, + azure-cli-extensions, + enableBitbucket ? false, + bitbucket-cli, + enableClaude ? false, + claude-code, + enableCodex ? true, + codex, + enableCursor ? false, + code-cursor, + enableCursorCli ? false, + cursor-cli, + enableGitHub ? true, + gh, + enableGit ? true, + git, + enableGitLab ? false, + glab, + enableJujutsu ? false, + jujutsu, + enableOpencode ? false, + opencode, + t3code-unwrapped ? callPackage ./unwrapped.nix { }, +}: + +let + runtimePackages = + lib.optionals enableAzureDevOps [ + (azure-cli.withExtensions [ azure-cli-extensions.azure-devops ]) + ] + ++ lib.optionals enableBitbucket [ bitbucket-cli ] + ++ lib.optionals enableClaude [ claude-code ] + ++ lib.optionals enableCodex [ codex ] + ++ lib.optionals enableCursor [ code-cursor ] + ++ lib.optionals enableCursorCli [ cursor-cli ] + ++ lib.optionals enableGitHub [ gh ] + ++ lib.optionals enableGit [ git ] + ++ lib.optionals enableGitLab [ glab ] + ++ lib.optionals enableJujutsu [ jujutsu ] + ++ lib.optionals enableOpencode [ opencode ]; + +in +symlinkJoin { + pname = "t3code"; + inherit (t3code-unwrapped) version; + __structuredAttrs = true; + strictDeps = true; + + paths = [ t3code-unwrapped ]; + + nativeBuildInputs = [ makeBinaryWrapper ]; + + postBuild = lib.optionalString (runtimePackages != [ ]) '' + for program in "$out/bin"/*; do + wrapProgram "$program" \ + --prefix PATH : "${lib.makeBinPath runtimePackages}" + done + ''; + + passthru = { + unwrapped = t3code-unwrapped; + } + // t3code-unwrapped.passthru; + + meta = { + # Manually inherit so that pos works + inherit (t3code-unwrapped.meta) + description + homepage + downloadPage + changelog + license + maintainers + mainProgram + platforms + ; + }; +} diff --git a/pkgs/by-name/t3/t3code/unwrapped.nix b/pkgs/by-name/t3/t3code/unwrapped.nix index 835c397f59ca..eddfbebb6874 100644 --- a/pkgs/by-name/t3/t3code/unwrapped.nix +++ b/pkgs/by-name/t3/t3code/unwrapped.nix @@ -20,29 +20,6 @@ pnpmConfigHook, pnpmBuildHook, cacert, - enableAzureDevOps ? false, - azure-cli, - azure-cli-extensions, - enableBitbucket ? false, - bitbucket-cli, - enableClaude ? false, - claude-code, - enableCodex ? true, - codex, - enableCursor ? false, - code-cursor, - enableCursorCli ? false, - cursor-cli, - enableGitHub ? true, - gh, - enableGit ? true, - git, - enableGitLab ? false, - glab, - enableJujutsu ? false, - jujutsu, - enableOpencode ? false, - opencode, }: stdenv.mkDerivation ( @@ -57,29 +34,9 @@ stdenv.mkDerivation ( else "assets/prod/black-universal-1024.png"; - runtimePackages = - lib.optionals enableAzureDevOps [ - azure-cli.withExtensions - [ azure-cli-extensions.azure-devops ] - ] - ++ lib.optionals enableBitbucket [ bitbucket-cli ] - ++ lib.optionals enableClaude [ claude-code ] - ++ lib.optionals enableCodex [ codex ] - ++ lib.optionals enableCursor [ code-cursor ] - ++ lib.optionals enableCursorCli [ cursor-cli ] - ++ lib.optionals enableGitHub [ gh ] - ++ lib.optionals enableGit [ git ] - ++ lib.optionals enableGitLab [ glab ] - ++ lib.optionals enableJujutsu [ jujutsu ] - ++ lib.optionals enableOpencode [ opencode ]; - - runtimePathWrapperArgs = lib.optionalString (runtimePackages != [ ]) '' - \ - --prefix PATH : ${lib.makeBinPath runtimePackages} - ''; in { - pname = "t3code"; + pname = "t3code-unwrapped"; version = "0.0.28"; strictDeps = true; __structuredAttrs = true; @@ -182,11 +139,11 @@ stdenv.mkDerivation ( find "$out"/libexec/t3code -xtype l -delete makeWrapper ${lib.getExe nodejs} "$out"/bin/t3 \ - --add-flags "$out"/libexec/t3code/apps/server/dist/bin.mjs ${runtimePathWrapperArgs} + --add-flags "$out"/libexec/t3code/apps/server/dist/bin.mjs makeWrapper ${lib.getExe electron} "$out"/bin/t3code-desktop \ --add-flags "$out"/libexec/t3code/apps/desktop \ - --inherit-argv0 ${runtimePathWrapperArgs} + --inherit-argv0 '' + lib.optionalString stdenv.hostPlatform.isDarwin '' # node-pty tries to chmod this helper at runtime, but the Nix store is @@ -236,7 +193,10 @@ stdenv.mkDerivation ( ]; passthru = { - updateScript = nix-update-script { }; + updateScript = nix-update-script { + attrPath = "t3code.unwrapped"; + extraArgs = [ "--use-github-releases" ]; + }; }; meta = {