Skip to content

Commit ce380fb

Browse files
authored
fix(nix): install opencode and keep opencode2 alias (#48662)
1 parent 3045156 commit ce380fb

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

‎nix/desktop.nix‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ stdenv.mkDerivation (finalAttrs: {
9090
export OPENCODE_CLI_DIST="$TMPDIR/desktop-cli"
9191
cli_package=$(bun -e 'import { getCurrentCli } from "./scripts/utils.ts"; console.log(getCurrentCli().package.replace("@opencode/", ""))')
9292
mkdir -p "$OPENCODE_CLI_DIST/$cli_package/bin"
93-
cp ${lib.getExe opencode} "$OPENCODE_CLI_DIST/$cli_package/bin/opencode2"
93+
cp ${lib.getExe opencode} "$OPENCODE_CLI_DIST/$cli_package/bin/opencode"
9494
9595
bun run build
9696
npx electron-builder --dir \

‎nix/opencode.nix‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ stdenvNoCC.mkDerivation (finalAttrs: {
6262
installPhase = ''
6363
runHook preInstall
6464
65-
install -Dm755 dist/cli-*/bin/opencode2 $out/bin/opencode2
65+
install -Dm755 dist/cli-*/bin/opencode $out/bin/opencode
6666
67-
wrapProgram $out/bin/opencode2 \
67+
wrapProgram $out/bin/opencode \
6868
--prefix PATH : ${
6969
lib.makeBinPath (
7070
[
@@ -75,11 +75,17 @@ stdenvNoCC.mkDerivation (finalAttrs: {
7575
)
7676
}
7777
78+
ln -s opencode $out/bin/opencode2
79+
7880
runHook postInstall
7981
'';
8082

8183
postInstall = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
8284
# trick yargs into also generating zsh completions
85+
installShellCompletion --cmd opencode \
86+
--bash <($out/bin/opencode completion) \
87+
--zsh <(SHELL=/bin/zsh $out/bin/opencode completion)
88+
8389
installShellCompletion --cmd opencode2 \
8490
--bash <($out/bin/opencode2 completion) \
8591
--zsh <(SHELL=/bin/zsh $out/bin/opencode2 completion)
@@ -101,7 +107,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
101107
description = "The open source coding agent";
102108
homepage = "https://opencode.ai";
103109
license = lib.licenses.mit;
104-
mainProgram = "opencode2";
110+
mainProgram = "opencode";
105111
inherit (node_modules.meta) platforms;
106112
};
107113
})

0 commit comments

Comments
 (0)