openAgent
gitlabThe open source UNIVERSAL agent.
clone
https://gitlab.com/bitzzdev/openAgent.gitAIagentautomationopen-sourceuniversal-agent
{lib,stdenvNoCC,callPackage,bun,nodejs,sysctl,makeBinaryWrapper,models-dev,ripgrep,installShellFiles,versionCheckHook,writableTmpDirAsHomeHook,node_modules ? callPackage ./node-modules.nix { },}:stdenvNoCC.mkDerivation (finalAttrs: {pname = "opencode";inherit (node_modules) version src;inherit node_modules;nativeBuildInputs = [bunnodejs # for patchShebangs node_modulesinstallShellFilesmakeBinaryWrappermodels-devwritableTmpDirAsHomeHook];postPatch = ''# NOTE: Relax Bun version check to be a warning instead of an errorsubstituteInPlace packages/script/src/index.ts \--replace-fail 'throw new Error(`This script requires bun@''${expectedBunVersionRange}' \'console.warn(`Warning: This script requires bun@''${expectedBunVersionRange}''';configurePhase = ''runHook preConfigurecp -R ${finalAttrs.node_modules}/. .patchShebangs node_modulespatchShebangs packages/*/node_modulesrunHook postConfigure'';env.MODELS_DEV_API_JSON = "${models-dev}/dist/_api.json";env.OPENCODE_DISABLE_MODELS_FETCH = true;env.OPENCODE_VERSION = finalAttrs.version;env.OPENCODE_CHANNEL = "prod";buildPhase = ''runHook preBuildcd ./packages/opencodebun --bun ./script/build.ts --single --skip-installbun --bun ./script/schema.ts schema.jsonrunHook postBuild'';installPhase = ''runHook preInstallinstall -Dm755 dist/opencode-*/bin/opencode $out/bin/opencodeinstall -Dm644 schema.json $out/share/opencode/schema.jsonwrapProgram $out/bin/opencode \--prefix PATH : ${lib.makeBinPath ([ripgrep]# bun runs sysctl to detect if running on rosetta2++ lib.optional stdenvNoCC.hostPlatform.isDarwin sysctl)}runHook postInstall'';postInstall = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''# trick yargs into also generating zsh completionsinstallShellCompletion --cmd opencode \--bash <($out/bin/opencode completion) \--zsh <(SHELL=/bin/zsh $out/bin/opencode completion)'';nativeInstallCheckInputs = [versionCheckHookwritableTmpDirAsHomeHook];doInstallCheck = true;versionCheckKeepEnvironment = [ "HOME" "OPENCODE_DISABLE_MODELS_FETCH" ];versionCheckProgramArg = "--version";passthru = {jsonschema = "${placeholder "out"}/share/opencode/schema.json";env = finalAttrs.env;};meta = {description = "The open source coding agent";homepage = "https://opencode.ai";license = lib.licenses.mit;mainProgram = "opencode";inherit (node_modules.meta) platforms;};})