opencode: incorporate upstream changes and simplify build

Remove unnecessary build customizations that are no longer required:
- Drop patch removing special build targets (fixed upstream)
- Remove preBuild hook (builds successfully without it)
- Remove fzf PATH addition (no longer needed)

Add sysctl to nativeBuildInputs on Darwin to properly detect Rosetta 2
execution environment.

Enable zsh completions by tricking yargs into generating them.
This commit is contained in:
Thierry Delafontaine
2026-01-28 13:09:12 +01:00
parent 88097c3e74
commit 75473fb2df
2 changed files with 11 additions and 121 deletions
+11 -21
View File
@@ -3,11 +3,11 @@
stdenvNoCC,
bun,
fetchFromGitHub,
fzf,
makeBinaryWrapper,
models-dev,
nix-update-script,
ripgrep,
sysctl,
installShellFiles,
versionCheckHook,
writableTmpDirAsHomeHook,
@@ -81,11 +81,6 @@ stdenvNoCC.mkDerivation (finalAttrs: {
writableTmpDirAsHomeHook
];
patches = [
# NOTE: Remove special and windows build targes
./remove-special-and-windows-build-targets.patch
];
postPatch = ''
# NOTE: Relax Bun version check to be a warning instead of an error
substituteInPlace packages/script/src/index.ts \
@@ -105,16 +100,6 @@ stdenvNoCC.mkDerivation (finalAttrs: {
env.OPENCODE_VERSION = finalAttrs.version;
env.OPENCODE_CHANNEL = "stable";
preBuild = ''
chmod -R u+w ./packages/opencode/node_modules
pushd ./packages/opencode/node_modules/@opentui/
for pkg in ../../../../node_modules/.bun/@opentui+core-*; do
linkName=$(basename "$pkg" | sed 's/@.*+\(.*\)@.*/\1/')
ln -sf "$pkg/node_modules/@opentui/$linkName" "$linkName"
done
popd
'';
buildPhase = ''
runHook preBuild
@@ -136,16 +121,21 @@ stdenvNoCC.mkDerivation (finalAttrs: {
postInstall = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
installShellCompletion --cmd opencode \
--bash <($out/bin/opencode completion)
--bash <($out/bin/opencode completion) \
--zsh <(SHELL=/bin/zsh $out/bin/opencode completion)
'';
postFixup = ''
wrapProgram $out/bin/opencode \
--prefix PATH : ${
lib.makeBinPath [
fzf
ripgrep
]
lib.makeBinPath (
[
ripgrep
]
++ lib.optionals stdenvNoCC.hostPlatform.isDarwin [
sysctl
]
)
}
'';
@@ -1,100 +0,0 @@
From 4d0a82e8f3cf8bf011e2592677db4aa31b6b290b Mon Sep 17 00:00:00 2001
From: Thierry Delafontaine <delafthi@pm.me>
Date: Sun, 4 Jan 2026 20:55:49 +0100
Subject: [PATCH] Remove special and windows build targets
---
packages/opencode/script/build.ts | 70 +++++++++++++++----------------
1 file changed, 35 insertions(+), 35 deletions(-)
diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts
index f51cb2924..ee3c0e863 100755
--- a/packages/opencode/script/build.ts
+++ b/packages/opencode/script/build.ts
@@ -33,27 +33,27 @@ const allTargets: {
os: "linux",
arch: "x64",
},
- {
- os: "linux",
- arch: "x64",
- avx2: false,
- },
- {
- os: "linux",
- arch: "arm64",
- abi: "musl",
- },
- {
- os: "linux",
- arch: "x64",
- abi: "musl",
- },
- {
- os: "linux",
- arch: "x64",
- abi: "musl",
- avx2: false,
- },
+ // {
+ // os: "linux",
+ // arch: "x64",
+ // avx2: false,
+ // },
+ // {
+ // os: "linux",
+ // arch: "arm64",
+ // abi: "musl",
+ // },
+ // {
+ // os: "linux",
+ // arch: "x64",
+ // abi: "musl",
+ // },
+ // {
+ // os: "linux",
+ // arch: "x64",
+ // abi: "musl",
+ // avx2: false,
+ // },
{
os: "darwin",
arch: "arm64",
@@ -62,20 +62,20 @@ const allTargets: {
os: "darwin",
arch: "x64",
},
- {
- os: "darwin",
- arch: "x64",
- avx2: false,
- },
- {
- os: "win32",
- arch: "x64",
- },
- {
- os: "win32",
- arch: "x64",
- avx2: false,
- },
+ // {
+ // os: "darwin",
+ // arch: "x64",
+ // avx2: false,
+ // },
+ // {
+ // os: "win32",
+ // arch: "x64",
+ // },
+ // {
+ // os: "win32",
+ // arch: "x64",
+ // avx2: false,
+ // },
]
const targets = singleFlag
--
2.52.0