Skip to content

Commit cc91747

Browse files
committed
fix(nix): repair three packaging defects on the v2 branch
`nix/opencode.nix` generates completions through `opencode completion`, which v2 removed: the Effect CLI parses it as the optional `directory` argument, so the TUI opens instead and `installShellCompletion` gets a zero-size file. It now uses the global `--completions <shell>` flag, and renames the opencode2 copies because the command name is a build-time define. Fish ships now; `sh` is a synonym for `bash`, so --bash already covers it. `nix/electron.nix` carries the electron 42.10.1 hashes while `packages/desktop/package.json` moved to 44.4.3, so the desktop's electron fetchzip cannot resolve. Refreshed from the 44.4.3 SHASUMS256.txt; the headers hash recomputed the same way the 42.10.1 one was, reproducing it as a control. `nix/desktop.nix` stages the CLI executable but not the manifest that `packages/desktop/scripts/utils.ts` reads the version from, so `scripts/prebuild.ts` aborts on a missing package.json. Fixes anomalyco#50408
1 parent dd786c6 commit cc91747

3 files changed

Lines changed: 27 additions & 11 deletions

File tree

‎nix/desktop.nix‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ stdenv.mkDerivation (finalAttrs: {
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"
9393
cp ${lib.getExe opencode} "$OPENCODE_CLI_DIST/$cli_package/bin/opencode"
94+
# scripts/utils.ts reads only the version from the manifest beside the
95+
# binary, and the CLI build's own name does not match $cli_package.
96+
printf '{"version":"%s"}\n' "$version" > "$OPENCODE_CLI_DIST/$cli_package/package.json"
9497
9598
bun run build
9699
npx electron-builder --dir \

‎nix/electron.nix‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ let
33
version = (builtins.fromJSON (builtins.readFile ../packages/desktop/package.json)).devDependencies.electron;
44
in
55
(callPackage (path + "/pkgs/development/tools/electron/binary/generic.nix") { }) version {
6-
# Electron 42.10.1 SHASUMS256.txt; update with the desktop package version.
7-
aarch64-linux = "20e68d6c4e47f3ebf59de7c6b1f8b8bec6a6ebda6a451132f9b465f3f13ce467";
8-
x86_64-linux = "2452b27112d92387471fa2488aafac85d79ea3f2ee1216c0abd5150d6c12362b";
9-
aarch64-darwin = "ac7194a3dfd81930ba35355c01620262c1254752859b42dcb8f4b9e4d174a871";
10-
x86_64-darwin = "4489aba55477a0082266cb690db1c829503ba3338048599d8fd243953df37dab";
6+
# Electron 44.4.3 SHASUMS256.txt; update with the desktop package version.
7+
aarch64-linux = "61f084a5ac0f1835efc12b9db17042d92c8c617b03578f96a888acd4a05a0b10";
8+
x86_64-linux = "fe880a7e37160cfd4e00193bc4c713ead7a778abfe74860a2d36d86fd0be48a8";
9+
aarch64-darwin = "6b728f5dcfae74f3f936f2bca5b3cd9b9659ffea464f67939f004acb55425a85";
10+
x86_64-darwin = "015b52631d92187b552ff4e047255f596a7af4707e388a5890951f0b2645764e";
1111
# fetchzip hashes the unpacked headers, not the release tarball.
12-
headers = "sha256-4eUy3BZVvxTl7KUOsxio7769lL6ag/ecbeK+qLURWMI=";
12+
headers = "sha256-QPkX+99kArlQhhbgOZe+Hsk28G5cadkUy0G0cIDtEh8=";
1313
}

‎nix/opencode.nix‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,27 @@ stdenvNoCC.mkDerivation (finalAttrs: {
8585
'';
8686

8787
postInstall = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
88-
# trick yargs into also generating zsh completions
88+
# v2 dropped the `completion` subcommand; --completions is the global flag.
89+
# NOTE: staged to files, installShellCompletion only rejects a zero-size file.
90+
$out/bin/opencode --completions bash > opencode.bash
91+
$out/bin/opencode --completions zsh > _opencode
92+
$out/bin/opencode --completions fish > opencode.fish
93+
8994
installShellCompletion --cmd opencode \
90-
--bash <($out/bin/opencode completion) \
91-
--zsh <(SHELL=/bin/zsh $out/bin/opencode completion)
95+
--bash opencode.bash \
96+
--fish opencode.fish \
97+
--zsh _opencode
98+
99+
# OPENCODE_CLI_NAME is a build-time define, so the opencode2 copies are
100+
# renamed rather than regenerated.
101+
substitute opencode.bash opencode2.bash --replace-fail opencode opencode2
102+
substitute _opencode _opencode2 --replace-fail opencode opencode2
103+
substitute opencode.fish opencode2.fish --replace-fail opencode opencode2
92104
93105
installShellCompletion --cmd opencode2 \
94-
--bash <($out/bin/opencode2 completion) \
95-
--zsh <(SHELL=/bin/zsh $out/bin/opencode2 completion)
106+
--bash opencode2.bash \
107+
--fish opencode2.fish \
108+
--zsh _opencode2
96109
'';
97110

98111
nativeInstallCheckInputs = [

0 commit comments

Comments
 (0)