feat(packages): add g3
CI / check (push) Has been cancelled

Pinned commit: upstream has no tags. Ships g3 and g3-studio.

Closes nix-overlay-ikz
This commit is contained in:
2026-09-23 14:52:31 +03:00
parent 5f848a82a3
commit c437841a86
3 changed files with 102 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
{
lib,
stdenv,
rustPlatform,
fetchFromGitHub,
pkg-config,
openssl,
cmake,
libx11,
libxtst,
llvmPackages,
}:
rustPlatform.buildRustPackage rec {
pname = "g3";
# Upstream has no git tags or releases; pin main and let nix-update
# track the branch. Version shape matches nix-update --version=branch=main
# for a tagless repository (package version is 0.1.0 upstream).
version = "0.1.0-unstable-2026-09-06";
src = fetchFromGitHub {
owner = "dhanji";
repo = "g3";
rev = "9793144520d290a9ea621a06cf7d8322e6fa4a35";
hash = "sha256-s4QlOah7ffoFjiTw2nO/SbCbvIRxr4HB/3pOpQpGWRM=";
};
# Cargo.lock has a git dependency (tree-sitter-haskell); cargoHash /
# fetchCargoVendor covers registry + git sources.
cargoHash = "sha256-6dvN4//NNuo9s5QzTcrxYiNkxP0Ivysg6f1F9soFrL4=";
nativeBuildInputs = [
pkg-config
cmake
# llama-cpp-sys-2 runs bindgen, which needs libclang.
llvmPackages.libclang
];
buildInputs = [
openssl
libx11
libxtst
];
# bindgen (via llama-cpp-sys-2) needs libclang and the C library headers.
env = {
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
BINDGEN_EXTRA_CLANG_ARGS = "-isystem ${lib.getDev stdenv.cc.libc}/include";
};
# Root package only builds/installs its own bins; studio is a sibling
# workspace member. Match upstream install.sh: ship g3 and studio
# (renamed to g3-studio).
cargoBuildFlags = [
"-p"
"g3"
"-p"
"studio"
];
cargoInstallFlags = [
"-p"
"g3"
"-p"
"studio"
];
# Provider and computer-control tests need network, LLM credentials, and a
# display; not runnable in the Nix sandbox.
doCheck = false;
# Upstream install.sh names the companion workspace manager g3-studio.
postInstall = ''
mv "$out/bin/studio" "$out/bin/g3-studio"
'';
passthru = {
category = "AI Coding Agents";
updateScript = [
"nix-update"
"--flake"
".#g3"
"--version=branch=main"
];
};
meta = with lib; {
description = "AI coding agent that writes code and executes commands, with multi-provider LLM support, context compaction, and desktop automation";
homepage = "https://github.com/dhanji/g3";
# Cargo.toml declares MIT; the repository ships no LICENSE file.
license = licenses.mit;
sourceProvenance = with sourceTypes; [ fromSource ];
mainProgram = "g3";
platforms = platforms.unix;
};
}