Unverified Commit 28367ae7 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

opencode: incorporate upstream changes and simplify build (#484668)

parents 917af71a 75473fb2
Loading
Loading
Loading
Loading
+11 −21
Original line number Diff line number Diff line
@@ -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
       lib.makeBinPath (
         [
           ripgrep
         ]
         ++ lib.optionals stdenvNoCC.hostPlatform.isDarwin [
           sysctl
         ]
       )
     }
  '';

+0 −100
Original line number Diff line number Diff line
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