up
This commit is contained in:
45
flake.lock
generated
45
flake.lock
generated
@@ -81,26 +81,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"disko": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1753140376,
|
||||
"narHash": "sha256-7lrVrE0jSvZHrxEzvnfHFE/Wkk9DDqb+mYCodI5uuB8=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "545aba02960caa78a31bd9a8709a0ad4b6320a5c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
@@ -184,11 +164,11 @@
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1754920958,
|
||||
"narHash": "sha256-id7UDxIVVpRrcIt+y5gJQA8TEHLo4xcrrkuikIX+TQk=",
|
||||
"lastModified": 1754924470,
|
||||
"narHash": "sha256-asI/or9AcUMydwzodCgpHGytnMSNUlciw3uaycpXm4E=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "e11d6c321f3f848178a3fb2a8984aa5fe08c0996",
|
||||
"rev": "67393957c27b4e4c6c48a60108a201413ced7800",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -216,11 +196,11 @@
|
||||
"homebrew-cask": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1754920273,
|
||||
"narHash": "sha256-YYbCs8TV5n9WuYgNLJlmVtq7pv5JKlQ+HxGp/gH/aZ4=",
|
||||
"lastModified": 1754931713,
|
||||
"narHash": "sha256-8ar1jlSF1PoaAbkaDH/YOKjkTmXiOj+yrojL3Ppf7LQ=",
|
||||
"owner": "homebrew",
|
||||
"repo": "homebrew-cask",
|
||||
"rev": "42a9951dac62afe5dcd4364cfb0c38fe7bf08ae6",
|
||||
"rev": "a3abcd193aff0596af28b6849eda437dd1baa84f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -232,11 +212,11 @@
|
||||
"homebrew-core": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1754920235,
|
||||
"narHash": "sha256-mhb5fC3AXxKzvckSO6LDnzy4Q2RQvUm8mb38kJOsl5Q=",
|
||||
"lastModified": 1754929321,
|
||||
"narHash": "sha256-0NHsn08/bSSxt13o8zAYtaSuD2M4aziTS8t9o7DvCus=",
|
||||
"owner": "homebrew",
|
||||
"repo": "homebrew-core",
|
||||
"rev": "120959346c9ef2a21c4021f5a0a407a873d4d3b0",
|
||||
"rev": "d939090d6bdf40b8a5cbbbc8b49eb78ec6b8f445",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -378,11 +358,11 @@
|
||||
"systems": "systems_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1754682350,
|
||||
"narHash": "sha256-4Dgf0cA/ZJtj9eTzG0yNMRBcd5fll3hhWx2WdwltAP8=",
|
||||
"lastModified": 1754921951,
|
||||
"narHash": "sha256-KY+/livAp6l3fI8SdNa+CLN/AA4Z038yL/pQL2PaW7g=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixvim",
|
||||
"rev": "832de87d40f9a40430372552ab0b583680187cf3",
|
||||
"rev": "7b53322d75a1c66f84fb145e4b5f0f411d9edc6b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -418,7 +398,6 @@
|
||||
"inputs": {
|
||||
"agenix": "agenix",
|
||||
"darwin": "darwin_2",
|
||||
"disko": "disko",
|
||||
"flake-parts": "flake-parts",
|
||||
"home-manager": "home-manager_2",
|
||||
"homebrew-axe": "homebrew-axe",
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
url = "github:cameroncooke/homebrew-axe";
|
||||
flake = false;
|
||||
};
|
||||
disko = {
|
||||
url = "github:nix-community/disko";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nixvim.url = "github:nix-community/nixvim";
|
||||
};
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
final: prev: {
|
||||
opencode = final.callPackage ./opencode/default.nix { };
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
stdenvNoCC,
|
||||
buildGoModule,
|
||||
bun,
|
||||
fetchFromGitHub,
|
||||
makeBinaryWrapper,
|
||||
models-dev,
|
||||
nix-update-script,
|
||||
testers,
|
||||
writableTmpDirAsHomeHook,
|
||||
}:
|
||||
|
||||
let
|
||||
opencode-node-modules-hash = {
|
||||
"aarch64-darwin" = "sha256-LNp9sLhNUUC4ujLYPvfPx423GlXuIS0Z2H512H5oY8s=";
|
||||
"aarch64-linux" = "sha256-xeKZwNV4ScF9p1vAcVR+vk4BiEpUH+AOGb7DQ2vLl1I=";
|
||||
"x86_64-darwin" = "sha256-4NaHXeWf57dGVV+KP3mBSIUkbIApT19BuADT0E4X+rg=";
|
||||
"x86_64-linux" = "sha256-7Hc3FJcg2dA8AvGQlS082fO1ehGBMPXWPF8N+sAHh2I=";
|
||||
};
|
||||
bun-target = {
|
||||
"aarch64-darwin" = "bun-darwin-arm64";
|
||||
"aarch64-linux" = "bun-linux-arm64";
|
||||
"x86_64-darwin" = "bun-darwin-x64";
|
||||
"x86_64-linux" = "bun-linux-x64";
|
||||
};
|
||||
in
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pname = "opencode";
|
||||
version = "0.4.1";
|
||||
src = fetchFromGitHub {
|
||||
owner = "sst";
|
||||
repo = "opencode";
|
||||
tag = "v${finalAttrs.version}";
|
||||
hash = "sha256-LEFmfsqhCuGcRK7CEPZb6EZfjOHAyYpUHptXu04fjpQ=";
|
||||
};
|
||||
|
||||
tui = buildGoModule {
|
||||
pname = "opencode-tui";
|
||||
inherit (finalAttrs) version src;
|
||||
|
||||
modRoot = "packages/tui";
|
||||
|
||||
vendorHash = "sha256-jGaTgKyAvBMt8Js5JrPFUayhVt3QhgyclFoNatoHac4=";
|
||||
|
||||
subPackages = [ "cmd/opencode" ];
|
||||
|
||||
env.CGO_ENABLED = 0;
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-X=main.Version=${finalAttrs.version}"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm755 $GOPATH/bin/opencode $out/bin/tui
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
};
|
||||
|
||||
node_modules = stdenvNoCC.mkDerivation {
|
||||
pname = "opencode-node_modules";
|
||||
inherit (finalAttrs) version src;
|
||||
|
||||
impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [
|
||||
"GIT_PROXY_COMMAND"
|
||||
"SOCKS_SERVER"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
bun
|
||||
writableTmpDirAsHomeHook
|
||||
];
|
||||
|
||||
dontConfigure = true;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
|
||||
|
||||
bun install \
|
||||
--filter=opencode \
|
||||
--force \
|
||||
--frozen-lockfile \
|
||||
--no-progress
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/node_modules
|
||||
cp -R ./node_modules $out
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# Required else we get errors that our fixed-output derivation references store paths
|
||||
dontFixup = true;
|
||||
|
||||
outputHash = opencode-node-modules-hash.${stdenvNoCC.hostPlatform.system};
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
bun
|
||||
makeBinaryWrapper
|
||||
models-dev
|
||||
];
|
||||
|
||||
patches = [
|
||||
# Patch `packages/opencode/src/provider/models-macro.ts` to get contents of
|
||||
# `_api.json` from the file bundled with `bun build`.
|
||||
./local-models-dev.patch
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
cp -R ${finalAttrs.node_modules}/node_modules .
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
env.MODELS_DEV_API_JSON = "${models-dev}/dist/_api.json";
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
bun build \
|
||||
--define OPENCODE_TUI_PATH="'${finalAttrs.tui}/bin/tui'" \
|
||||
--define OPENCODE_VERSION="'${finalAttrs.version}'" \
|
||||
--compile \
|
||||
--target=${bun-target.${stdenvNoCC.hostPlatform.system}} \
|
||||
--outfile=opencode \
|
||||
./packages/opencode/src/index.ts \
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
dontStrip = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm755 opencode $out/bin/opencode
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
# Add runtime dependencies for libstdc++.so.6
|
||||
postFixup = ''
|
||||
wrapProgram $out/bin/opencode \
|
||||
--set LD_LIBRARY_PATH "${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}"
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
tests.version = testers.testVersion {
|
||||
package = finalAttrs.finalPackage;
|
||||
command = "HOME=$(mktemp -d) opencode --version";
|
||||
inherit (finalAttrs) version;
|
||||
};
|
||||
updateScript = nix-update-script {
|
||||
extraArgs = [
|
||||
"--subpackage"
|
||||
"tui"
|
||||
"--subpackage"
|
||||
"node_modules"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "AI coding agent built for the terminal";
|
||||
longDescription = ''
|
||||
OpenCode is a terminal-based agent that can build anything.
|
||||
It combines a TypeScript/JavaScript core with a Go-based TUI
|
||||
to provide an interactive AI coding experience.
|
||||
'';
|
||||
homepage = "https://github.com/sst/opencode";
|
||||
license = lib.licenses.mit;
|
||||
platforms = lib.platforms.unix;
|
||||
maintainers = with lib.maintainers; [
|
||||
zestsystem
|
||||
delafthi
|
||||
];
|
||||
mainProgram = "opencode";
|
||||
};
|
||||
})
|
||||
@@ -1,20 +0,0 @@
|
||||
diff --git i/packages/opencode/src/provider/models-macro.ts w/packages/opencode/src/provider/models-macro.ts
|
||||
index 91a0348..4f60069 100644
|
||||
--- i/packages/opencode/src/provider/models-macro.ts
|
||||
+++ w/packages/opencode/src/provider/models-macro.ts
|
||||
@@ -1,4 +1,15 @@
|
||||
export async function data() {
|
||||
+ const localApiJsonPath = process.env.MODELS_DEV_API_JSON
|
||||
+
|
||||
+ // Try to read from local file if path is provided
|
||||
+ if (localApiJsonPath) {
|
||||
+ const localFile = Bun.file(localApiJsonPath)
|
||||
+ if (await localFile.exists()) {
|
||||
+ return await localFile.text()
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Fallback to fetching from remote URL
|
||||
const json = await fetch("https://models.dev/api.json").then((x) => x.text())
|
||||
return json
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
expandtab = true;
|
||||
shiftwidth = 2;
|
||||
relativenumber = true;
|
||||
mouse = "";
|
||||
# foldmethod = "expr";
|
||||
# foldexpr = "nvim_treesitter#foldexpr()";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user