diff --git a/pkgs/by-name/op/opencode/hashes.json b/pkgs/by-name/op/opencode/hashes.json index 77927f0f7894..24ab419ee9bc 100644 --- a/pkgs/by-name/op/opencode/hashes.json +++ b/pkgs/by-name/op/opencode/hashes.json @@ -1,8 +1,8 @@ { "node_modules": { - "aarch64-linux": "3yXOsptDRUoyL/FBQu8esD4ipudOA9jyLenNt1WChMU=", - "x86_64-linux": "sha256-ocgmxMx+V6uBMLZTrHfYAqO4l38WQVCrQ2AbUWagaoM=", - "aarch64-darwin": "sha256-xNU+ucIy84iqmyoWKwwLBIV34TTmH/OGmIbIiNOPM/w=", - "x86_64-darwin": "sha256-9kplc7tpWgYnB+4471EBkE2xYF3RkpgKqpg26M6bUPs=" + "aarch64-linux": "sha256-uqOotHS6p5mLBmh3f7lka9boXBz7trTKuGahGfOSTD4=", + "x86_64-linux": "sha256-qlVlP5ayYTuf/uZIW7lk8wKYxArB0jOHmw94yK9v9Bg=", + "aarch64-darwin": "sha256-dDKVLmE33P9epJFmsUluDjtyVL5jT87atpv8qbEFy7o=", + "x86_64-darwin": "sha256-eBsU9hSf1tRfp8ErZtmM731YVtVRZ8ovQ5nYmokaPD0=" } } diff --git a/pkgs/by-name/op/opencode/local-models-dev.patch b/pkgs/by-name/op/opencode/local-models-dev.patch deleted file mode 100644 index 21ecd38fb0c8..000000000000 --- a/pkgs/by-name/op/opencode/local-models-dev.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git i/packages/opencode/src/provider/models-macro.ts w/packages/opencode/src/provider/models-macro.ts -index 91a0348..4f60069 100644 ---- i/packages/opencode/src/provider/models-macro.ts -+++ w/packages/opencode/src/provider/models-macro.ts -@@ -1,4 +1,15 @@ - export async function data() { -+ const localApiJsonPath = process.env.MODELS_DEV_API_JSON -+ -+ // Try to read from local file if path is provided -+ if (localApiJsonPath) { -+ const localFile = Bun.file(localApiJsonPath) -+ if (await localFile.exists()) { -+ return await localFile.text() -+ } -+ } -+ -+ // Fallback to fetching from remote URL - const json = await fetch("https://models.dev/api.json").then((x) => x.text()) - return json - } diff --git a/pkgs/by-name/op/opencode/package.nix b/pkgs/by-name/op/opencode/package.nix index ab7e65fab508..3f28f7940ca0 100644 --- a/pkgs/by-name/op/opencode/package.nix +++ b/pkgs/by-name/op/opencode/package.nix @@ -14,12 +14,12 @@ stdenvNoCC.mkDerivation (finalAttrs: { pname = "opencode"; - version = "1.0.45"; + version = "1.0.78"; src = fetchFromGitHub { owner = "sst"; repo = "opencode"; tag = "v${finalAttrs.version}"; - hash = "sha256-59nsauILNEvQ4Q8ATHKtgTViIWMaFnUyBf7CN6qrtdk="; + hash = "sha256-o+rNkij9niggHkA+TtexTbrXLK0I9Ol1Cp9NC/wEuAk="; }; node_modules = stdenvNoCC.mkDerivation { @@ -80,9 +80,6 @@ stdenvNoCC.mkDerivation (finalAttrs: { ]; patches = [ - # NOTE: Patch `packages/opencode/src/provider/models-macro.ts` to get contents of - # `_api.json` from the file bundled with `bun build`. - ./local-models-dev.patch # NOTE: Skip npm pack commands in build.ts since packages are already in node_modules ./skip-npm-pack.patch ]; @@ -168,5 +165,9 @@ stdenvNoCC.mkDerivation (finalAttrs: { license = lib.licenses.mit; platforms = lib.platforms.unix; mainProgram = "opencode"; + badPlatforms = [ + # Problems with bun >= 1.3.2, see https://github.com/oven-sh/bun/issues/24645 + lib.systems.inspect.patterns.isDarwin + ]; }; }) diff --git a/pkgs/by-name/op/opencode/skip-npm-pack.patch b/pkgs/by-name/op/opencode/skip-npm-pack.patch index 67825e14e99a..7b912be349ae 100644 --- a/pkgs/by-name/op/opencode/skip-npm-pack.patch +++ b/pkgs/by-name/op/opencode/skip-npm-pack.patch @@ -1,22 +1,27 @@ diff --git i/packages/opencode/script/build.ts w/packages/opencode/script/build.ts -index 29706c09..584b00d4 100755 +index 502baed..f854e99 100755 --- i/packages/opencode/script/build.ts +++ w/packages/opencode/script/build.ts -@@ -39,15 +39,9 @@ for (const [os, arch] of targets) { - const name = `${pkg.name}-${os}-${arch}` - await $`mkdir -p dist/${name}/bin` +@@ -77,14 +77,19 @@ const allTargets: { + ] -- const opentui = `@opentui/core-${os === "windows" ? "win32" : os}-${arch.replace("-baseline", "")}` -- await $`mkdir -p ../../node_modules/${opentui}` -- await $`npm pack ${opentui}@${pkg.dependencies["@opentui/core"]}`.cwd(path.join(dir, "../../node_modules")) -- await $`tar -xf ../../node_modules/${opentui.replace("@opentui/", "opentui-")}-*.tgz -C ../../node_modules/${opentui} --strip-components=1` -+ // Skip npm pack - packages already installed in node_modules by Nix + const targets = singleFlag +- ? allTargets.filter((item) => item.os === process.platform && item.arch === process.arch) ++ ? allTargets.filter((item) => ++ item.os === process.platform && ++ item.arch === process.arch && ++ item.avx2 !== false && ++ item.abi === undefined ++ ).slice(0, 1) + : allTargets -- const watcher = `@parcel/watcher-${os === "windows" ? "win32" : os}-${arch.replace("-baseline", "")}${os === "linux" ? "-glibc" : ""}` -- await $`mkdir -p ../../node_modules/${watcher}` -- await $`npm pack ${watcher}`.cwd(path.join(dir, "../../node_modules")).quiet() -- await $`tar -xf ../../node_modules/${watcher.replace("@parcel/", "parcel-")}-*.tgz -C ../../node_modules/${watcher} --strip-components=1` -+ // Skip npm pack - packages already installed in node_modules by Nix + await $`rm -rf dist` - const parserWorker = fs.realpathSync(path.resolve(dir, "./node_modules/@opentui/core/parser.worker.js")) - const workerPath = "./src/cli/cmd/tui/worker.ts" + const binaries: Record = {} +-await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]}` +-await $`bun install --os="*" --cpu="*" @parcel/watcher@${pkg.dependencies["@parcel/watcher"]}` ++// Skip bun install - packages already installed in node_modules by Nix ++// Skip bun install - packages already installed in node_modules by Nix + for (const item of targets) { + const name = [ + pkg.name,