feat: update opencode to 1.1.60 with bun patch and desktop outputHashes
This commit is contained in:
@@ -1,23 +1,129 @@
|
||||
{ lib, stdenv, symlinkJoin, makeWrapper, inputs ? null, }:
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
symlinkJoin,
|
||||
makeWrapper,
|
||||
rustPlatform,
|
||||
pkg-config,
|
||||
cargo-tauri,
|
||||
bun,
|
||||
nodejs,
|
||||
cargo,
|
||||
rustc,
|
||||
jq,
|
||||
wrapGAppsHook4,
|
||||
dbus,
|
||||
glib,
|
||||
gtk4,
|
||||
libsoup_3,
|
||||
librsvg,
|
||||
libappindicator,
|
||||
glib-networking,
|
||||
openssl,
|
||||
webkitgtk_4_1,
|
||||
gst_all_1,
|
||||
inputs ? null,
|
||||
...
|
||||
}:
|
||||
let
|
||||
# Get opencode package for version, src, node_modules
|
||||
opencode-pkg = inputs.opencode.packages.${stdenv.hostPlatform.system}.opencode;
|
||||
|
||||
# Workaround for https://github.com/anomalyco/opencode/issues/11755
|
||||
# specta git dependencies need explicit outputHashes for Nix build
|
||||
# We rebuild the desktop package with the outputHashes
|
||||
opencode-desktop =
|
||||
inputs.opencode.packages.${stdenv.hostPlatform.system}.desktop;
|
||||
in symlinkJoin {
|
||||
name = "opencode-desktop";
|
||||
paths = [ opencode-desktop ];
|
||||
rustPlatform.buildRustPackage (finalAttrs: {
|
||||
pname = "opencode-desktop";
|
||||
version = opencode-pkg.version;
|
||||
src = opencode-pkg.src;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
cargoRoot = "packages/desktop/src-tauri";
|
||||
cargoLock = {
|
||||
lockFile = opencode-pkg.src + "/packages/desktop/src-tauri/Cargo.lock";
|
||||
outputHashes = {
|
||||
"specta-2.0.0-rc.22" = "sha256-YsyOAnXELLKzhNlJ35dHA6KGbs0wTAX/nlQoW8wWyJQ=";
|
||||
"tauri-2.9.5" = "sha256-dv5E/+A49ZBvnUQUkCGGJ21iHrVvrhHKNcpUctivJ8M=";
|
||||
"tauri-specta-2.0.0-rc.21" = "sha256-n2VJ+B1nVrh6zQoZyfMoctqP+Csh7eVHRXwUQuiQjaQ=";
|
||||
};
|
||||
};
|
||||
buildAndTestSubdir = finalAttrs.cargoRoot;
|
||||
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/opencode-desktop \
|
||||
--run 'if [[ "$NIXOS_OZONE_WL" == "1" ]]; then export OC_ALLOW_WAYLAND=1; fi'
|
||||
'';
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
cargo-tauri.hook
|
||||
bun
|
||||
nodejs
|
||||
cargo
|
||||
rustc
|
||||
jq
|
||||
makeWrapper
|
||||
] ++ lib.optionals stdenv.hostPlatform.isLinux [wrapGAppsHook4];
|
||||
|
||||
meta = {
|
||||
description = "OpenCode Desktop App with Wayland support";
|
||||
homepage = "https://opencode.ai";
|
||||
license = lib.licenses.mit;
|
||||
platforms = lib.platforms.linux;
|
||||
mainProgram = "opencode-desktop";
|
||||
};
|
||||
}
|
||||
buildInputs = lib.optionals stdenv.isLinux [
|
||||
dbus
|
||||
glib
|
||||
gtk4
|
||||
libsoup_3
|
||||
librsvg
|
||||
libappindicator
|
||||
glib-networking
|
||||
openssl
|
||||
webkitgtk_4_1
|
||||
gst_all_1.gstreamer
|
||||
gst_all_1.gst-plugins-base
|
||||
gst_all_1.gst-plugins-good
|
||||
gst_all_1.gst-plugins-bad
|
||||
];
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
preBuild = ''
|
||||
cp -a ${opencode-pkg.node_modules}/{node_modules,packages} .
|
||||
chmod -R u+w node_modules packages
|
||||
patchShebangs node_modules
|
||||
patchShebangs packages/desktop/node_modules
|
||||
|
||||
mkdir -p packages/desktop/src-tauri/sidecars
|
||||
cp ${opencode-pkg}/bin/opencode packages/desktop/src-tauri/sidecars/opencode-cli-${stdenv.hostPlatform.rust.rustcTarget}
|
||||
'';
|
||||
|
||||
tauriBuildFlags = [
|
||||
"--config"
|
||||
"tauri.prod.conf.json"
|
||||
"--no-sign"
|
||||
];
|
||||
|
||||
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
|
||||
mv $out/bin/OpenCode $out/bin/opencode-desktop
|
||||
sed -i 's|^Exec=OpenCode$|Exec=opencode-desktop|' $out/share/applications/OpenCode.desktop
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "OpenCode Desktop App";
|
||||
homepage = "https://opencode.ai";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "opencode-desktop";
|
||||
platforms = lib.platforms.linux ++ lib.platforms.darwin;
|
||||
};
|
||||
});
|
||||
in
|
||||
symlinkJoin {
|
||||
name = "opencode-desktop";
|
||||
paths = [opencode-desktop];
|
||||
|
||||
nativeBuildInputs = [makeWrapper];
|
||||
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/opencode-desktop \
|
||||
--run 'if [[ "$NIXOS_OZONE_WL" == "1" ]]; then export OC_ALLOW_WAYLAND=1; fi'
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "OpenCode Desktop App with Wayland support";
|
||||
homepage = "https://opencode.ai";
|
||||
license = lib.licenses.mit;
|
||||
platforms = lib.platforms.linux;
|
||||
mainProgram = "opencode-desktop";
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user