# Copyright 2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 inherit shell-completion # xAI stopped publishing the source at 1.0.45 (2026-09-29); the binaries are # taken from the npm platform packages that the official installer uses. DESCRIPTION="SpaceXAI's coding agent harness and TUI (prebuilt binary)" HOMEPAGE=" https://x.ai/cli https://github.com/xai-org/grok-build " SRC_URI=" amd64? ( https://registry.npmjs.org/@xai-official/grok-linux-x64/-/grok-linux-x64-${PV}.tgz -> ${P}-x64.tgz ) arm64? ( https://registry.npmjs.org/@xai-official/grok-linux-arm64/-/grok-linux-arm64-${PV}.tgz -> ${P}-arm64.tgz ) " S="${WORKDIR}/package" LICENSE="Apache-2.0" # Bundled crates and the bundled rg, ugrep and bfs binaries LICENSE+=" 0BSD Apache-2.0 BSD-2 BSD Boost-1.0 CC0-1.0 CDLA-Permissive-2.0 EPL-2.0 ISC MIT MIT-0 MPL-2.0 Unicode-3.0 Unicode-DFS-2016 Unlicense WTFPL-2 ZLIB " SLOT="0" KEYWORDS="-* ~amd64 ~arm64" RESTRICT="strip" RDEPEND="!dev-util/grok-build" BDEPEND="app-arch/brotli" QA_PREBUILT="usr/bin/grok" src_compile() { # Shipped brotli-compressed to stay under npm's size limit brotli -d -o grok bin/grok.br || die chmod 0755 grok || die # Keep the binary away from the build user's real home local -x HOME="${T}/home" GROK_HOME="${T}/home/.grok" ./grok completions bash > grok.bash || die ./grok completions fish > grok.fish || die ./grok completions zsh > _grok || die } src_install() { dobin grok dosym grok /usr/bin/agent newbashcomp grok.bash grok dofishcomp grok.fish dozshcomp _grok # Portage owns updates. requirements.toml is the highest config tier, # so this overrides every user's own config. insinto /etc/grok doins "${FILESDIR}"/requirements.toml dodoc README.md THIRD_PARTY_NOTICES.md } pkg_postinst() { elog "Automatic updates are turned off in /etc/grok/requirements.toml;" elog "update grok through Portage. An explicit \`grok update\` still" elog "installs a separate copy under ~/.grok/bin." }