feat: update opencode to 1.1.60 with bun patch and desktop outputHashes
This commit is contained in:
8
flake.lock
generated
8
flake.lock
generated
@@ -37,16 +37,16 @@
|
|||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1770817534,
|
"lastModified": 1770875904,
|
||||||
"narHash": "sha256-AcLT70Gjt78nDd13ACUDavE+QI+ouEBwyZq8hIDDAf8=",
|
"narHash": "sha256-8ZEVlGe1saA/2KtDTKgkwWfpLCbxfwFip+m+3FlQQK0=",
|
||||||
"owner": "anomalyco",
|
"owner": "anomalyco",
|
||||||
"repo": "opencode",
|
"repo": "opencode",
|
||||||
"rev": "edcfd562af6ea5fdc1ade9f46259a676d7663801",
|
"rev": "03de51bd3cf9e05bd92c9f51763b74a3cdfbe61a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "anomalyco",
|
"owner": "anomalyco",
|
||||||
"ref": "v1.1.57",
|
"ref": "v1.1.60",
|
||||||
"repo": "opencode",
|
"repo": "opencode",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
opencode.url = "github:anomalyco/opencode/v1.1.59";
|
opencode.url = "github:anomalyco/opencode/v1.1.60";
|
||||||
|
|
||||||
# Optional: Add stable channel if needed
|
# Optional: Add stable channel if needed
|
||||||
# nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
|
# nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
|
||||||
|
|||||||
@@ -2,7 +2,15 @@
|
|||||||
pkgs,
|
pkgs,
|
||||||
inputs ? null,
|
inputs ? null,
|
||||||
...
|
...
|
||||||
}: {
|
}: let
|
||||||
|
# Upstream opencode v1.1.60 strictly requires Bun ^1.3.9 but nixpkgs provides 1.3.8
|
||||||
|
# We patch package.json to match the environment version to fix the build
|
||||||
|
opencode = inputs.opencode.packages.${pkgs.system}.opencode.overrideAttrs (old: {
|
||||||
|
postPatch = (old.postPatch or "") + ''
|
||||||
|
substituteInPlace package.json --replace-fail '"packageManager": "bun@1.3.9"' '"packageManager": "bun@1.3.8"'
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
in {
|
||||||
# Custom packages registry
|
# Custom packages registry
|
||||||
# Each package is defined in its own directory under pkgs/
|
# Each package is defined in its own directory under pkgs/
|
||||||
beads = pkgs.callPackage ./beads {};
|
beads = pkgs.callPackage ./beads {};
|
||||||
@@ -21,6 +29,6 @@
|
|||||||
zellij-ps = pkgs.callPackage ./zellij-ps {};
|
zellij-ps = pkgs.callPackage ./zellij-ps {};
|
||||||
|
|
||||||
# Imported from flake inputs
|
# Imported from flake inputs
|
||||||
opencode = inputs.opencode.packages.${pkgs.system}.opencode;
|
inherit opencode;
|
||||||
# opencode-desktop = pkgs.callPackage ./opencode-desktop { inherit inputs; };
|
opencode-desktop = pkgs.callPackage ./opencode-desktop {inherit inputs;};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,114 @@
|
|||||||
{ 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
|
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 =
|
opencode-desktop =
|
||||||
inputs.opencode.packages.${stdenv.hostPlatform.system}.desktop;
|
rustPlatform.buildRustPackage (finalAttrs: {
|
||||||
in symlinkJoin {
|
pname = "opencode-desktop";
|
||||||
|
version = opencode-pkg.version;
|
||||||
|
src = opencode-pkg.src;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkg-config
|
||||||
|
cargo-tauri.hook
|
||||||
|
bun
|
||||||
|
nodejs
|
||||||
|
cargo
|
||||||
|
rustc
|
||||||
|
jq
|
||||||
|
makeWrapper
|
||||||
|
] ++ lib.optionals stdenv.hostPlatform.isLinux [wrapGAppsHook4];
|
||||||
|
|
||||||
|
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";
|
name = "opencode-desktop";
|
||||||
paths = [opencode-desktop];
|
paths = [opencode-desktop];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user