From a075f1311ce40ae1b9008fdc43b38d0b2e53b961 Mon Sep 17 00:00:00 2001 From: superherointj Date: Mon, 11 May 2026 08:47:42 -0300 Subject: [PATCH 1/2] opencode: 1.14.35 -> 1.14.48 - https://github.com/anomalyco/opencode/releases/tag/v1.14.48 - https://github.com/anomalyco/opencode/releases/tag/v1.14.47 - https://github.com/anomalyco/opencode/releases/tag/v1.14.46 - https://github.com/anomalyco/opencode/releases/tag/v1.14.45 - https://github.com/anomalyco/opencode/releases/tag/v1.14.44 - https://github.com/anomalyco/opencode/releases/tag/v1.14.43 - https://github.com/anomalyco/opencode/releases/tag/v1.14.42 - https://github.com/anomalyco/opencode/releases/tag/v1.14.41 - https://github.com/anomalyco/opencode/releases/tag/v1.14.40 - https://github.com/anomalyco/opencode/releases/tag/v1.14.39 - https://github.com/anomalyco/opencode/releases/tag/v1.14.38 - https://github.com/anomalyco/opencode/releases/tag/v1.14.37 --- pkgs/by-name/op/opencode/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/op/opencode/package.nix b/pkgs/by-name/op/opencode/package.nix index 1c3d1a2b63ac..d4bcfb1d45a5 100644 --- a/pkgs/by-name/op/opencode/package.nix +++ b/pkgs/by-name/op/opencode/package.nix @@ -16,13 +16,13 @@ stdenvNoCC.mkDerivation (finalAttrs: { pname = "opencode"; - version = "1.14.35"; + version = "1.14.48"; src = fetchFromGitHub { owner = "anomalyco"; repo = "opencode"; tag = "v${finalAttrs.version}"; - hash = "sha256-i2Ct4QC0Tf+UWNWAQoW/IPtRKrVyZSC1/FTzQNpou2g="; + hash = "sha256-gyybqabTco+5ZeWv4lCX8t/R9Jm3tYsA8wVvkrxkEYQ="; }; node_modules = stdenvNoCC.mkDerivation { @@ -75,7 +75,7 @@ stdenvNoCC.mkDerivation (finalAttrs: { # NOTE: Required else we get errors that our fixed-output derivation references store paths dontFixup = true; - outputHash = "sha256-JwkXBlXS4AG0rquzdOSE5Atzm0Hm9UVEBmDMAnTlbyg="; + outputHash = "sha256-94uXrhyGqW016U6LPE/xIfZGoDOzyUto5DyQrYYePds="; outputHashAlgo = "sha256"; outputHashMode = "recursive"; }; From 50b75f108d1d0e60dccc694ed98cddedbbe237d7 Mon Sep 17 00:00:00 2001 From: superherointj Date: Mon, 11 May 2026 08:48:07 -0300 Subject: [PATCH 2/2] opencode-desktop: rewrite from Tauri to Electron The upstream desktop app was completely rewritten from Tauri/Rust to Electron. Rewrite the Nix packaging to match: - Replace rustPlatform.buildRustPackage with stdenvNoCC.mkDerivation - Use electron_41 instead of cargo-tauri - Build with electron-vite and package with electron-builder - Embed opencode CLI as sidecar binary opencode-desktop: fix aarch64-linux install path electron-builder --dir outputs to linux-arm64-unpacked on aarch64 (not linux-unpacked). Use a glob pattern to support both. opencode-desktop: fix linux install path for aarch64 electron-builder outputs to linux-arm64-unpacked on aarch64-linux and linux-unpacked on x86_64-linux. Use hostPlatform.isAarch64 to select the correct directory in installPhase. Previously used a bash glob (linux-*-unpacked) which failed to match in the nix build sandbox. --- pkgs/by-name/op/opencode-desktop/package.nix | 160 +++++++++++-------- 1 file changed, 96 insertions(+), 64 deletions(-) diff --git a/pkgs/by-name/op/opencode-desktop/package.nix b/pkgs/by-name/op/opencode-desktop/package.nix index 24b16ea6f866..9ca30437f227 100644 --- a/pkgs/by-name/op/opencode-desktop/package.nix +++ b/pkgs/by-name/op/opencode-desktop/package.nix @@ -1,35 +1,22 @@ { bun, - cargo, - cargo-tauri, - dbus, - glib, - glib-networking, - gst_all_1, - gtk4, - jq, + copyDesktopItems, + electron_41, lib, - libappindicator, - librsvg, - libsoup_3, makeBinaryWrapper, + models-dev, nodejs, opencode, - openssl, - pkg-config, - rustPlatform, - rustc, stdenvNoCC, - webkitgtk_4_1, - wrapGAppsHook4, + writableTmpDirAsHomeHook, + + commandLineArgs ? "", }: let - gtk = gtk4; - libsoup = libsoup_3; - webkitgtk = webkitgtk_4_1; + electron = electron_41; in -rustPlatform.buildRustPackage (finalAttrs: { +stdenvNoCC.mkDerivation (finalAttrs: { pname = "opencode-desktop"; inherit (opencode) version @@ -38,55 +25,100 @@ rustPlatform.buildRustPackage (finalAttrs: { patches ; - cargoRoot = "packages/desktop/src-tauri"; - cargoHash = "sha256-WI48iYdxmizF1YgOQtk05dvrBEMqFjHP9s3+zBFAat0="; - buildAndTestSubdir = finalAttrs.cargoRoot; - nativeBuildInputs = [ - pkg-config - cargo-tauri.hook bun nodejs # for patchShebangs node_modules - cargo - rustc - jq makeBinaryWrapper - ] - ++ lib.optionals stdenvNoCC.hostPlatform.isLinux [ wrapGAppsHook4 ]; - - buildInputs = ( - lib.optionals stdenvNoCC.isLinux [ - dbus - glib - glib-networking - gtk - libappindicator - librsvg - libsoup - openssl - webkitgtk - ] - ++ (with gst_all_1; [ - gst-plugins-bad # fakevideosink - gst-plugins-base # appsink and autoaudiosink - gst-plugins-good # autoaudiosink - ]) - ); - - tauriBuildFlags = [ - "--config" - "tauri.conf.json" - "--config" - "tauri.prod.conf.json" - "--no-sign" + writableTmpDirAsHomeHook + copyDesktopItems ]; - preBuild = '' - cp -a ${finalAttrs.node_modules}/{node_modules,packages} . - chmod -R u+w node_modules packages - patchShebangs node_modules packages/desktop/node_modules - install -D ${lib.getExe opencode} \ - packages/desktop/src-tauri/sidecars/opencode-cli-${stdenvNoCC.hostPlatform.rust.rustcTarget} + strictDeps = true; + + env = { + ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; + OPENCODE_CHANNEL = "prod"; + MODELS_DEV_API_JSON = "${models-dev}/dist/_api.json"; + OPENCODE_DISABLE_MODELS_FETCH = true; + }; + + configurePhase = '' + runHook preConfigure + + cp -R ${finalAttrs.node_modules}/. . + patchShebangs node_modules + patchShebangs packages/*/node_modules + + runHook postConfigure + ''; + + buildPhase = '' + runHook preBuild + + # Build the opencode node bundle (needed by the desktop sidecar) + cd packages/opencode + bun --bun ./script/build-node.ts --skip-install + cd ../.. + + # Prepare desktop app + cd packages/desktop + + # Copy prod icons + cp -R icons/prod resources/icons + + # Build with electron-vite + node_modules/.bin/electron-vite build + + # Copy opencode CLI as sidecar + sidecar_name="opencode-cli" + install -D ${lib.getExe opencode} "resources/$sidecar_name" + + # Package with electron-builder (unpacked directory mode) + cp -r "${electron.dist}" $HOME/.electron-dist + chmod -R u+w $HOME/.electron-dist + + node_modules/.bin/electron-builder --dir \ + --config=electron-builder.config.ts \ + --config.electronDist="$HOME/.electron-dist" \ + --config.electronVersion=${electron.version} + + cd ../.. + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + '' + + lib.optionalString stdenvNoCC.hostPlatform.isDarwin '' + mkdir -p $out/Applications + mv packages/desktop/dist/mac-*/OpenCode.app "$out/Applications/OpenCode.app" + '' + + lib.optionalString stdenvNoCC.hostPlatform.isLinux '' + mkdir -p $out/opt/opencode-desktop + ${ + if stdenvNoCC.hostPlatform.isAarch64 then + '' + appDir="packages/desktop/dist/linux-arm64-unpacked" + '' + else + '' + appDir="packages/desktop/dist/linux-unpacked" + '' + } + [ -d "$appDir" ] || { echo "no electron-builder output dir found: $appDir"; exit 1; } + cp -r "$appDir/resources" $out/opt/opencode-desktop/ + + install -Dm644 packages/desktop/resources/icons/icon.png $out/share/icons/opencode-desktop.png + + makeWrapper ${lib.getExe electron} $out/bin/opencode-desktop \ + --inherit-argv0 \ + --add-flags $out/opt/opencode-desktop/resources/app.asar \ + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true --wayland-text-input-version=3}}" \ + --add-flags ${lib.escapeShellArg commandLineArgs} + '' + + '' + runHook postInstall ''; meta = {