Files
millerson-overlay.nix/packages/goose-cli/package.nix
Alexander Miroshnichenko 4a06f35ec2
Some checks failed
CI / check (push) Has been cancelled
fix(goose-cli): resolve bindgen and test failures in Nix sandbox
- Added stdenv and BINDGEN_EXTRA_CLANG_ARGS to fix libclang header
  resolution for llama-cpp-sys-2 bindgen (stdio.h not found)
- Added cmake to nativeBuildInputs (required by llama-cpp-sys-2 build)
- Added cacert and SSL_CERT_FILE to fix reqwest CA certificate errors
  in tests (No CA certificates were loaded from the system)
- All 191 tests now pass in the sandbox
2026-05-08 20:13:34 +03:00

95 lines
2.3 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
rustPlatform,
pkg-config,
cmake,
cacert,
openssl,
libxcb,
dbus,
versionCheckHook,
librusty_v8,
llvmPackages,
}:
rustPlatform.buildRustPackage rec {
pname = "goose-cli";
version = "1.33.1";
src = fetchFromGitHub {
owner = "block";
repo = "goose";
rev = "v${version}";
hash = "sha256-FBICGOfVs2jbOdLWSInqfTYBdnCcbcGWHwqY/b6v8eg=";
};
cargoHash = "sha256-fN0FKDYFkZrQQPWdUlemOaGzIAZhqFyskz9TEmG+X4o=";
nativeBuildInputs = [
pkg-config
cmake
llvmPackages.libclang
];
buildInputs = [
openssl
libxcb
dbus
];
# The v8 package will try to download a `librusty_v8.a` release at build time to our read-only filesystem
# To avoid this we pre-download the file and export it via RUSTY_V8_ARCHIVE
env.RUSTY_V8_ARCHIVE = librusty_v8;
# bindgen (used by llama-cpp-sys-2) needs libclang and C headers
env.LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
env.BINDGEN_EXTRA_CLANG_ARGS = "-isystem ${lib.getDev stdenv.cc.libc}/include";
# reqwest needs CA certificates in the sandbox
env.SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
# Build only the CLI package
cargoBuildFlags = [
"--package"
"goose-cli"
];
# Enable tests with proper environment
doCheck = true;
checkPhase = ''
export HOME=$(mktemp -d)
export XDG_CONFIG_HOME=$HOME/.config
export XDG_DATA_HOME=$HOME/.local/share
export XDG_STATE_HOME=$HOME/.local/state
export XDG_CACHE_HOME=$HOME/.cache
mkdir -p $XDG_CONFIG_HOME $XDG_DATA_HOME $XDG_STATE_HOME $XDG_CACHE_HOME
# Run tests for goose-cli package only
cargo test --package goose-cli
'';
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
passthru = {
category = "AI Coding Agents";
updateScript = [
"nix-update"
"--flake"
".#goose-cli"
];
};
meta = {
description = "CLI for Goose - a local, extensible, open source AI agent that automates engineering tasks";
homepage = "https://github.com/block/goose";
changelog = "https://github.com/block/goose/releases/tag/v${version}";
license = lib.licenses.asl20;
sourceProvenance = with lib.sourceTypes; [ fromSource ];
mainProgram = "goose";
platforms = lib.platforms.all;
};
}