Some checks failed
Update Nix Packages with nix-update / nix-update (push) Failing after 1s
- Update opencode flake input to v1.1.60 - Add nixpkgs-master input for opencode (needs newer bun) - Re-enable opencode-desktop with workaround for upstream issue #11755 - Add specta/tauri outputHashes for git dependencies - Add .todos/ to gitignore - Update AGENTS.md with td task management instructions
107 lines
2.9 KiB
Nix
107 lines
2.9 KiB
Nix
{
|
|
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 upstream opencode package for shared attributes
|
|
opencode = inputs.opencode.packages.${stdenv.hostPlatform.system}.default;
|
|
|
|
# Workaround for https://github.com/anomalyco/opencode/issues/11755
|
|
# Upstream is missing outputHashes for git dependencies
|
|
opencode-desktop = rustPlatform.buildRustPackage (finalAttrs: {
|
|
pname = "opencode-desktop";
|
|
inherit (opencode) version src node_modules patches;
|
|
|
|
cargoRoot = "packages/desktop/src-tauri";
|
|
cargoLock = {
|
|
lockFile = finalAttrs.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 ${finalAttrs.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}/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
|
|
'';
|
|
});
|
|
# Wrapper for Wayland support
|
|
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";
|
|
};
|
|
}
|