Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
default = pkgs.mkShell {
packages = with pkgs; [
bun
nodejs_20
nodejs_26
pkg-config
openssl
git
Expand Down
4 changes: 2 additions & 2 deletions nix/desktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lib,
stdenv,
bun,
nodejs,
nodejs_26,
darwin,
electron_41,
makeWrapper,
Expand All @@ -24,7 +24,7 @@ stdenv.mkDerivation (finalAttrs: {

nativeBuildInputs = [
bun
nodejs
nodejs_26
makeWrapper
writableTmpDirAsHomeHook
] ++ lib.optionals stdenv.hostPlatform.isLinux [
Expand Down
25 changes: 20 additions & 5 deletions nix/opencode.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
stdenvNoCC,
callPackage,
bun,
nodejs,
nodejs_26,
sysctl,
makeBinaryWrapper,
models-dev,
Expand All @@ -20,7 +20,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {

nativeBuildInputs = [
bun
nodejs # for patchShebangs node_modules
nodejs_26 # for patchShebangs node_modules
installShellFiles
makeBinaryWrapper
models-dev
Expand All @@ -32,6 +32,11 @@ stdenvNoCC.mkDerivation (finalAttrs: {
substituteInPlace packages/script/src/index.ts \
--replace-fail 'throw new Error(`This script requires bun@''${expectedBunVersionRange}' \
'console.warn(`Warning: This script requires bun@''${expectedBunVersionRange}'

# Nix builds are network-restricted. Reuse the provided Node binary for SEA packaging
# instead of trying to download the exact upstream Node version at build time.
substituteInPlace packages/cli/script/build-node.ts \
--replace-fail ' if (info.version === NODE_VERSION) return realpath(info.path)' ' return realpath(info.path)'
'';

configurePhase = ''
Expand All @@ -48,21 +53,26 @@ stdenvNoCC.mkDerivation (finalAttrs: {
env.OPENCODE_DISABLE_MODELS_FETCH = true;
env.OPENCODE_VERSION = finalAttrs.version;
env.OPENCODE_CHANNEL = "prod";
env.NODE_BIN = "${nodejs_26}/bin/node";

buildPhase = ''
runHook preBuild

cd ./packages/opencode
bun --bun ./script/build.ts --single --skip-install
bun --bun ./script/schema.ts schema.json

cd ../cli
bun --bun ./script/build-node.ts --single --skip-install

cd ../opencode

runHook postBuild
'';

installPhase = ''
runHook preInstall

install -Dm755 dist/opencode-*/bin/opencode $out/bin/opencode
install -Dm755 ../cli/dist/cli-node-*/bin/opencode2-node $out/bin/opencode
install -Dm644 schema.json $out/share/opencode/schema.json

wrapProgram $out/bin/opencode \
Expand All @@ -76,6 +86,8 @@ stdenvNoCC.mkDerivation (finalAttrs: {
)
}

ln -s opencode $out/bin/opencode2

runHook postInstall
'';

Expand All @@ -91,7 +103,10 @@ stdenvNoCC.mkDerivation (finalAttrs: {
writableTmpDirAsHomeHook
];
doInstallCheck = true;
versionCheckKeepEnvironment = [ "HOME" "OPENCODE_DISABLE_MODELS_FETCH" ];
versionCheckKeepEnvironment = [
"HOME"
"OPENCODE_DISABLE_MODELS_FETCH"
];
versionCheckProgramArg = "--version";

passthru = {
Expand Down
Loading