mirror of
https://github.com/Heretek-AI/opencode.git
synced 2026-11-22 08:59:26 -10:00
+26


![opencode-agent[bot]](/assets/img/avatar_default.png)





![opencode-agent[bot]](/assets/img/avatar_default.png)
opencode-agent[bot]
opencode
Aiden Cline
Aiden Cline
Luke Parker
Adam
opencode-agent[bot]
Brendan Allan
Victor Navarro
Aarav Sareen
Frank
Dax Raad
Dax
Nabs
usrnk1
Brendan Allan
Vladimir Glafirov
AidenGeunGeun
Mark
Aiden Cline
David Hill
Jay
Jay
BB84
Dustin Deus
Jack
Sebastian
Jérôme Benoit
Test User
Simon Klee
Rahul A Mistry
Qiping Li
liqiping
OpeOginni
Matthias Reso
tobwen
4c9a4309ce
Co-authored-by: opencode <[email protected]> Co-authored-by: Aiden Cline <[email protected]> Co-authored-by: Aiden Cline <[email protected]> Co-authored-by: Luke Parker <[email protected]> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Adam <[email protected]> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Brendan Allan <[email protected]> Co-authored-by: Victor Navarro <[email protected]> Co-authored-by: Aarav Sareen <[email protected]> Co-authored-by: Frank <[email protected]> Co-authored-by: Dax Raad <[email protected]> Co-authored-by: Dax <[email protected]> Co-authored-by: Nabs <[email protected]> Co-authored-by: usrnk1 <[email protected]> Co-authored-by: Brendan Allan <[email protected]> Co-authored-by: Vladimir Glafirov <[email protected]> Co-authored-by: AidenGeunGeun <[email protected]> Co-authored-by: Mark <[email protected]> Co-authored-by: Aiden Cline <[email protected]> Co-authored-by: David Hill <[email protected]> Co-authored-by: Jay <[email protected]> Co-authored-by: Jay <[email protected]> Co-authored-by: BB84 <[email protected]> Co-authored-by: Dustin Deus <[email protected]> Co-authored-by: Jack <[email protected]> Co-authored-by: Sebastian <[email protected]> Co-authored-by: Jérôme Benoit <[email protected]> Co-authored-by: Test User <[email protected]> Co-authored-by: Simon Klee <[email protected]> Co-authored-by: Rahul A Mistry <[email protected]> Co-authored-by: Qiping Li <[email protected]> Co-authored-by: liqiping <[email protected]> Co-authored-by: OpeOginni <[email protected]> Co-authored-by: Matthias Reso <[email protected]> Co-authored-by: tobwen <[email protected]>
144 lines
4.2 KiB
Nix
144 lines
4.2 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
bun,
|
|
nodejs,
|
|
darwin,
|
|
electron_41,
|
|
makeWrapper,
|
|
writableTmpDirAsHomeHook,
|
|
autoPatchelfHook,
|
|
copyDesktopItems,
|
|
makeDesktopItem,
|
|
opencode,
|
|
}:
|
|
let
|
|
electron = electron_41;
|
|
in
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "opencode-desktop";
|
|
inherit (opencode)
|
|
version
|
|
src
|
|
node_modules
|
|
patches
|
|
;
|
|
|
|
nativeBuildInputs = [
|
|
bun
|
|
nodejs
|
|
makeWrapper
|
|
writableTmpDirAsHomeHook
|
|
]
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [
|
|
autoPatchelfHook
|
|
copyDesktopItems
|
|
]
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
# Ad-hoc sign the .app: --config.mac.identity=null below skips signing.
|
|
darwin.autoSignDarwinBinariesHook
|
|
];
|
|
|
|
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
|
(lib.getLib stdenv.cc.cc)
|
|
];
|
|
|
|
desktopItems = lib.optional stdenv.hostPlatform.isLinux (makeDesktopItem {
|
|
name = "ai.opencode.desktop";
|
|
desktopName = "OpenCode";
|
|
exec = "opencode-desktop %U";
|
|
icon = "ai.opencode.desktop";
|
|
# Electron 41 derives X11 WM_CLASS from app.name.
|
|
startupWMClass = "OpenCode";
|
|
categories = [ "Development" ];
|
|
});
|
|
|
|
env = opencode.env // {
|
|
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
|
};
|
|
|
|
postPatch =
|
|
# NOTE: Relax Bun version check to be a warning instead of an error
|
|
''
|
|
substituteInPlace packages/script/src/index.ts \
|
|
--replace-fail 'throw new Error(`This script requires bun@''${expectedBunVersionRange}' \
|
|
'console.warn(`Warning: This script requires bun@''${expectedBunVersionRange}'
|
|
''
|
|
# https://github.com/electron/electron/issues/31121
|
|
# mac builds use a .app bundle which doesnt have this issue
|
|
+ lib.optionalString stdenv.isLinux ''
|
|
BASE_PATH=packages/desktop
|
|
FILES=(src/main/windows.ts)
|
|
for file in "''${FILES[@]}"; do
|
|
substituteInPlace $BASE_PATH/$file \
|
|
--replace-fail "process.resourcesPath" "'$out/opt/opencode-desktop/resources'"
|
|
done
|
|
'';
|
|
|
|
preBuild = ''
|
|
cp -r "${electron.dist}" $HOME/.electron-dist
|
|
chmod -R u+w $HOME/.electron-dist
|
|
|
|
cp -R ${finalAttrs.node_modules}/. .
|
|
patchShebangs node_modules
|
|
patchShebangs packages/*/node_modules
|
|
'';
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
cd packages/desktop
|
|
|
|
bun run build
|
|
npx electron-builder --dir \
|
|
--config electron-builder.config.ts \
|
|
--config.mac.identity=null \
|
|
--config.electronDist="$HOME/.electron-dist"
|
|
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
''
|
|
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
mkdir -p $out/Applications
|
|
mv dist/mac*/*.app $out/Applications
|
|
makeWrapper "$out/Applications/OpenCode.app/Contents/MacOS/OpenCode" $out/bin/opencode-desktop
|
|
''
|
|
+ lib.optionalString stdenv.hostPlatform.isLinux ''
|
|
mkdir -p $out/opt/opencode-desktop
|
|
cp -r dist/linux*-unpacked/{resources,LICENSE*} $out/opt/opencode-desktop
|
|
install -Dm644 resources/icons/32x32.png \
|
|
"$out/share/icons/hicolor/32x32/apps/ai.opencode.desktop.png"
|
|
install -Dm644 resources/icons/64x64.png \
|
|
"$out/share/icons/hicolor/64x64/apps/ai.opencode.desktop.png"
|
|
install -Dm644 resources/icons/128x128.png \
|
|
"$out/share/icons/hicolor/128x128/apps/ai.opencode.desktop.png"
|
|
install -Dm644 resources/icons/[email protected] \
|
|
"$out/share/icons/hicolor/256x256/apps/ai.opencode.desktop.png"
|
|
install -Dm644 resources/icons/icon.png \
|
|
"$out/share/icons/hicolor/512x512/apps/ai.opencode.desktop.png"
|
|
install -Dm644 resources/ai.opencode.desktop.metainfo.xml \
|
|
"$out/share/metainfo/ai.opencode.desktop.metainfo.xml"
|
|
makeWrapper ${lib.getExe electron} $out/bin/opencode-desktop \
|
|
--inherit-argv0 \
|
|
--set ELECTRON_FORCE_IS_PACKAGED 1 \
|
|
--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}}"
|
|
''
|
|
+ ''
|
|
runHook postInstall
|
|
'';
|
|
|
|
autoPatchelfIgnoreMissingDeps = [
|
|
"libc.musl-x86_64.so.1"
|
|
];
|
|
|
|
meta = {
|
|
description = "OpenCode Desktop App";
|
|
mainProgram = "opencode-desktop";
|
|
inherit (opencode.meta) homepage license platforms;
|
|
};
|
|
})
|