Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 13 additions & 40 deletions nix/desktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
libappindicator-gtk3 ? null,
cargo,
rustc,
cargo-tauri,
makeBinaryWrapper,
copyDesktopItems,
makeDesktopItem,
nodejs,
jq,
}:
Expand Down Expand Up @@ -59,26 +58,11 @@ rustPlatform.buildRustPackage rec {
pkg-config
bun
makeBinaryWrapper
copyDesktopItems
cargo
rustc
nodejs
jq
];

# based on packages/desktop/src-tauri/release/appstream.metainfo.xml
desktopItems = lib.optionals stdenv.isLinux [
(makeDesktopItem {
name = "ai.opencode.opencode";
desktopName = "OpenCode";
comment = "Open source AI coding agent";
exec = "opencode-desktop";
icon = "opencode";
terminal = false;
type = "Application";
categories = [ "Development" "IDE" ];
startupWMClass = "opencode";
})
cargo-tauri.hook
];

buildInputs = [
Expand Down Expand Up @@ -116,35 +100,24 @@ rustPlatform.buildRustPackage rec {
targetTriple=${stdenv.hostPlatform.rust.rustcTarget}
cp ${args.opencode}/bin/opencode packages/desktop/src-tauri/sidecars/opencode-cli-$targetTriple

# Merge prod config into tauri.conf.json
if ! jq -s '.[0] * .[1]' \
packages/desktop/src-tauri/tauri.conf.json \
packages/desktop/src-tauri/tauri.prod.conf.json \
> packages/desktop/src-tauri/tauri.conf.json.tmp; then
echo "Error: failed to merge tauri.conf.json with tauri.prod.conf.json" >&2
exit 1
fi
mv packages/desktop/src-tauri/tauri.conf.json.tmp packages/desktop/src-tauri/tauri.conf.json

# Build the frontend
cd packages/desktop

# The 'build' script runs 'bun run typecheck && vite build'.
bun run build

popd
'';

# Tauri bundles the assets during the rust build phase (which happens after preBuild).
# It looks for them in the location specified in tauri.conf.json.

postInstall = lib.optionalString stdenv.isLinux ''
# Install icon
mkdir -p $out/share/icons/hicolor/128x128/apps
cp ../../../packages/desktop/src-tauri/icons/prod/128x128.png $out/share/icons/hicolor/128x128/apps/opencode.png
# Configurations are merged in the order they are provided
tauriBuildFlags = [
"--config"
"tauri.conf.json"
"--config"
"tauri.prod.conf.json"
"--no-sign"
];

postInstall = lib.optionalString stdenv.isLinux ''
# Wrap the binary to ensure it finds the libraries
wrapProgram $out/bin/opencode-desktop \
wrapProgram $out/bin/OpenCode \
Copy link
Contributor

@jerome-benoit jerome-benoit Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use case sensitive name that will collide with opencode on any case insensitive file system. Binary name is standardized: no space, etc. Do not change the name of an already shipped binary, already defined name at build, ...

Copy link
Contributor Author

@gigamonster256 gigamonster256 Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the desktop app ships as "OpenCode" on every other platform (ls showing extracted 1.1.25 releases for deb, rpm, and darwin app)

image

And i'm not changing the name of the binary, thats what the tauri bundler outputs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's true, it's a serious namespace collision between the TUI and the GUI binary that should be addressed and will break on most macOS installation. And bug should be opened.

--prefix LD_LIBRARY_PATH : ${
lib.makeLibraryPath [
gtk3
Expand All @@ -161,7 +134,7 @@ rustPlatform.buildRustPackage rec {
homepage = "https://opencode.ai";
license = licenses.mit;
maintainers = with maintainers; [ ];
mainProgram = "opencode-desktop";
mainProgram = "OpenCode";
platforms = platforms.linux ++ platforms.darwin;
};
}
Loading