Replace broken nixpkgs opencode with upstream linux-x64 release to avoid SystemPrompt.environment crashes.
51 lines
1.4 KiB
Nix
51 lines
1.4 KiB
Nix
# 官方预编译二进制:nixpkgs 用新版 bun 构建的 opencode 会在发 prompt 时
|
|
# 触发 SystemPrompt.environment 崩溃(Unexpected server error / a.name)。
|
|
{
|
|
lib,
|
|
stdenv,
|
|
fetchurl,
|
|
autoPatchelfHook,
|
|
makeWrapper,
|
|
ripgrep,
|
|
}:
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "opencode";
|
|
version = "1.18.31";
|
|
|
|
src = fetchurl {
|
|
url = "https://github.com/anomalyco/opencode/releases/download/v${finalAttrs.version}/opencode-linux-x64.tar.gz";
|
|
hash = "sha256-6TEr517YA7dBX8Kuq9ofT+k4kSo5Zzdi3Aw4wOEeveQ=";
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
autoPatchelfHook
|
|
makeWrapper
|
|
];
|
|
|
|
buildInputs = [ stdenv.cc.cc.lib ];
|
|
|
|
sourceRoot = ".";
|
|
|
|
dontStrip = true;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
install -Dm755 opencode $out/bin/.opencode-wrapped
|
|
makeWrapper $out/bin/.opencode-wrapped $out/bin/opencode \
|
|
--prefix PATH : ${lib.makeBinPath [ ripgrep ]} \
|
|
--set OPENCODE_DISABLE_AUTOUPDATE true
|
|
runHook postInstall
|
|
'';
|
|
|
|
meta = {
|
|
description = "AI coding agent built for the terminal (official binary; nixpkgs build is broken)";
|
|
homepage = "https://github.com/anomalyco/opencode";
|
|
changelog = "https://github.com/anomalyco/opencode/releases/tag/v${finalAttrs.version}";
|
|
license = lib.licenses.mit;
|
|
platforms = [ "x86_64-linux" ];
|
|
mainProgram = "opencode";
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
|
};
|
|
})
|