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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ This repository uses GitHub Actions to automatically update all packages and fla

- **Description**: CLI for Goose - a local, extensible, open source AI agent that automates engineering tasks
- **Version**: 1.3.1
- **Source**: binary
- **Source**: source
- **License**: Apache-2.0
- **Homepage**: https://github.com/block/goose
- **Usage**: `nix run .#goose-cli -- --help`
Expand Down
83 changes: 26 additions & 57 deletions packages/goose-cli/package.nix
Original file line number Diff line number Diff line change
@@ -1,82 +1,51 @@
{
lib,
rustPlatform,
fetchFromGitHub,
pkg-config,
openssl,
stdenv,
fetchurl,
autoPatchelfHook,
makeWrapper,
libxcb,
gcc,
darwin,
}:

let
rustPlatform.buildRustPackage rec {
pname = "goose-cli";
version = "1.3.1";

sources = {
x86_64-linux = {
url = "https://github.com/block/goose/releases/download/v${version}/goose-x86_64-unknown-linux-gnu.tar.bz2";
hash = "sha256-u/fpE5LdGReJrjUKhyMBThlImH7MGHdoLcHfakjFaCU=";
};
aarch64-linux = {
url = "https://github.com/block/goose/releases/download/v${version}/goose-aarch64-unknown-linux-gnu.tar.bz2";
hash = "sha256-zNiIQEYStyNQAswREyS1bK7XJcFij0wXqOuVraxBpis=";
};
x86_64-darwin = {
url = "https://github.com/block/goose/releases/download/v${version}/goose-x86_64-apple-darwin.tar.bz2";
hash = "sha256-Sng35OZ5qO3APBGzFNUQhtBf2K2idd/iHG1ca2yk/sg=";
};
aarch64-darwin = {
url = "https://github.com/block/goose/releases/download/v${version}/goose-aarch64-apple-darwin.tar.bz2";
hash = "sha256-v4UBFxk54nrnINJC4OB/0V29pX8uv2bR422QyLwQ9Lw=";
};
src = fetchFromGitHub {
owner = "block";
repo = "goose";
rev = "v${version}";
hash = "sha256-bb+GB+mBsnTwCOl8iuSUjm35mrhJGNdlyyU9EKSvlME=";
};

source =
sources.${stdenv.hostPlatform.system}
or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation rec {
pname = "goose-cli";
inherit version;

src = fetchurl source;
cargoHash = "sha256-AHAB3Bmyb+nkYCKWIo4ARkiidTjAaGIA0rz24QaF6Co=";

nativeBuildInputs = [
makeWrapper
]
++ lib.optionals stdenv.hostPlatform.isLinux [
autoPatchelfHook
pkg-config
];

buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
libxcb
gcc.cc.lib
buildInputs = [
openssl
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];

sourceRoot = ".";

installPhase = ''
runHook preInstall

mkdir -p $out/bin
cp goose $out/bin/goose
chmod +x $out/bin/goose

runHook postInstall
'';
# Build the goose CLI binary
cargoBuildFlags = [ "--package" "goose-cli" ];

# Skip tests for now
doCheck = false;

meta = with lib; {
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 = licenses.asl20;
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
sourceProvenance = with sourceTypes; [ fromSource ];
maintainers = with maintainers; [ ];
platforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
mainProgram = "goose";
platforms = platforms.all;
};
}
48 changes: 28 additions & 20 deletions packages/goose-cli/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,33 @@ echo "Latest version: $latest_version"
# Update version in package.nix
sed -i "s/version = \".*\"/version = \"$latest_version\"/" package.nix

# Update hashes for each platform
platforms=(
"x86_64-linux:x86_64-unknown-linux-gnu"
"aarch64-linux:aarch64-unknown-linux-gnu"
"x86_64-darwin:x86_64-apple-darwin"
"aarch64-darwin:aarch64-apple-darwin"
)

for platform_spec in "${platforms[@]}"; do
nix_platform="${platform_spec%%:*}"
goose_platform="${platform_spec##*:}"

url="https://github.com/block/goose/releases/download/v$latest_version/goose-$goose_platform.tar.bz2"

echo "Fetching hash for $nix_platform..."
hash=$(nix-prefetch-url --type sha256 "$url" 2>/dev/null | xargs -I {} nix hash convert --hash-algo sha256 {} 2>/dev/null || echo "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")

# Update the hash in package.nix
sed -i "/$nix_platform = {/,/};/ s|hash = \".*\"|hash = \"$hash\"|" package.nix
done
# Get source hash
echo "Getting source hash..."
src_hash=$(nix run nixpkgs#nix-prefetch-github -- block goose --rev "v$latest_version" 2>/dev/null | jq -r .hash)
echo "Source hash: $src_hash"

# Update source hash
sed -i "s|hash = \"sha256-[^\"]*\"|hash = \"$src_hash\"|g" package.nix

# Set dummy cargo hash to get the real one
sed -i 's|cargoHash = "sha256-[^"]*"|cargoHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="|' package.nix

# Build to get the correct cargo hash
echo "Building to get cargo vendor hash..."
if output=$(nix build ../..#goose-cli 2>&1); then
echo "Build succeeded with dummy hash - something is wrong!"
exit 1
else
# Extract the correct cargo hash
if cargo_hash=$(echo "$output" | grep -A2 "error: hash mismatch" | grep "got:" | sed 's/.*got:[[:space:]]*//' | head -1); then
echo "Cargo vendor hash: $cargo_hash"
sed -i "s|sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=|$cargo_hash|" package.nix
else
echo "ERROR: Could not extract cargo hash from build output"
echo "Build output:"
echo "$output" | tail -50
exit 1
fi
fi

echo "Update complete!"