From bb1d10119102c7a3b27fcf629c348f527b53277e Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 2 Nov 2026 22:53:48 -0600 Subject: [PATCH] fix(latest-cli): patch t3 SEA binary with pinned patchelf 0.15.2 patchelf 0.19.x (current nixpkgs, and what autoPatchelfHook drives) corrupts the t3 0.1.2 Node SEA binary: its rewrite segfaults at startup, which failed the fleet nixos switch on the t3 installCheck. Hold the main binary out of the hook pass and patch it with a pinned patchelf 0.15.2, the version the previous nixpkgs pin used to build working t3 outputs. Verified: package builds, installCheck passes, built server starts and serves HTTP 200. --- pkgs/latest-cli/default.nix | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pkgs/latest-cli/default.nix b/pkgs/latest-cli/default.nix index d2e2dafdf1..b2c07c00b6 100644 --- a/pkgs/latest-cli/default.nix +++ b/pkgs/latest-cli/default.nix @@ -342,6 +342,19 @@ in assert lib.assertMsg ( system == "x86_64-linux" ) "pkgs/latest-cli: t3 is a prebuilt x86_64-linux artifact; system is ${system}"; + let + # Pinned to the last patchelf known to patch the t3 SEA binary + # correctly (see the preFixup note in the derivation); the patchelf + # current nixpkgs ships (0.19.x) corrupts it. + patchelf0152 = stdenv.mkDerivation { + pname = "patchelf"; + version = "0.15.2"; + src = fetchurl { + url = "https://github.com/NixOS/patchelf/releases/download/0.15.2/patchelf-0.15.2.tar.bz2"; + hash = "sha256-F3RfVkFZyOIo/EEtplogSLhGxLa0Igt3y/IkFuAvLXw="; + }; + }; + in stdenvNoCC.mkDerivation rec { pname = "t3"; version = "0.1.2"; @@ -374,6 +387,33 @@ in runHook postInstall ''; + # The main `t3` binary is a Node single-executable (SEA) build, and + # patchelf 0.19.x -- the version current nixpkgs ships, and the one + # the autoPatchelfHook drives -- corrupts it: its rewrite of this + # binary's ELF layout segfaults at startup. Verified 2026-11-02 + # against the fleet-pin build: a 0.19.2-patched binary dies with + # SIGSEGV on `--version` inside and outside the build sandbox and + # is byte-identical to the failing build outputs, while patchelf + # 0.15.2 (what the previous nixpkgs pin used, which produced + # working t3 builds) patches it correctly. Every other file in the + # tree is patched fine by the hook, so the hook still handles the + # tree; the main binary is held out of its pass -- moved aside in + # preFixup, then restored and patched with the pinned patchelf + # 0.15.2 in preInstallCheck, after fixup completes -- so the + # installCheck below gates on exactly the binary that ships. + preFixup = '' + mv "$out/libexec/t3/t3" "$TMPDIR/t3-main-pristine" + ''; + + preInstallCheck = '' + mv "$TMPDIR/t3-main-pristine" "$out/libexec/t3/t3" + chmod +x "$out/libexec/t3/t3" + ${patchelf0152}/bin/patchelf \ + --set-interpreter "$(cat ${stdenv.cc}/nix-support/dynamic-linker)" \ + --set-rpath "${stdenv.cc.cc.lib}/lib:${stdenv.cc.cc.libgcc}/lib" \ + "$out/libexec/t3/t3" + ''; + doInstallCheck = true; installCheckPhase = '' runHook preInstallCheck