grok-build: init @ 0.2.82 (#538004)
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
{
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
fetchurl,
|
||||
installShellFiles,
|
||||
autoPatchelfHook,
|
||||
versionCheckHook,
|
||||
runCommand,
|
||||
testers,
|
||||
grok-build,
|
||||
}:
|
||||
let
|
||||
version = "0.2.82";
|
||||
|
||||
throwSystem = throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}";
|
||||
|
||||
platform = {
|
||||
x86_64-linux = "linux-x86_64";
|
||||
aarch64-linux = "linux-aarch64";
|
||||
x86_64-darwin = "macos-x86_64";
|
||||
aarch64-darwin = "macos-aarch64";
|
||||
};
|
||||
|
||||
sourceData = lib.mapAttrs (
|
||||
system: upstreamPlatform:
|
||||
fetchurl {
|
||||
url = "https://x.ai/cli/grok-${version}-${upstreamPlatform}";
|
||||
hash =
|
||||
{
|
||||
x86_64-linux = "sha256-x0+vJ1FB4WVIgCQY6/EHY5R+uqAPJCe7gPAiq6Y2iP4=";
|
||||
aarch64-linux = "sha256-tHJ8YAeG1ko++xn3OmyLlRsHWzXW+nypUZoIlBFQelg=";
|
||||
x86_64-darwin = "sha256-wCiGbPt50wH/he2VJhdqFD2rUiUznZL0Hj8hUo4+s5Y=";
|
||||
aarch64-darwin = "sha256-HkyKeLBQ2TVj4g9iKkGjT46WuAV1sclYrT8JUxb+YYk=";
|
||||
}
|
||||
.${system};
|
||||
}
|
||||
) platform;
|
||||
in
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pname = "grok-build";
|
||||
inherit version;
|
||||
|
||||
strictDeps = true;
|
||||
__structuredAttrs = true;
|
||||
|
||||
src = sourceData.${stdenvNoCC.hostPlatform.system} or throwSystem;
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
installShellFiles
|
||||
]
|
||||
++ lib.optionals stdenvNoCC.hostPlatform.isElf [ autoPatchelfHook ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm755 "$src" "$out/bin/grok"
|
||||
ln -s grok "$out/bin/agent"
|
||||
|
||||
${lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
|
||||
installShellCompletion --cmd grok \
|
||||
--bash <("$out/bin/grok" completions bash) \
|
||||
--fish <("$out/bin/grok" completions fish) \
|
||||
--zsh <("$out/bin/grok" completions zsh)
|
||||
''}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||
versionCheckProgramArg = "--version";
|
||||
|
||||
installCheckPhase = ''
|
||||
runHook preInstallCheck
|
||||
|
||||
# ensure is a symlink
|
||||
test -L "$out/bin/agent"
|
||||
|
||||
# ensure agent points at grok
|
||||
[ "$(readlink -f "$out/bin/agent")" = "$(readlink -f "$out/bin/grok")" ]
|
||||
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
|
||||
passthru.updateScript = ./update.sh;
|
||||
|
||||
meta = {
|
||||
description = "Command-line coding agent by xAI";
|
||||
homepage = "https://docs.x.ai/build/overview";
|
||||
downloadPage = "https://x.ai/cli/stable";
|
||||
license = lib.licenses.unfreeRedistributable;
|
||||
maintainers = with lib.maintainers; [ crertel ];
|
||||
platforms = lib.attrNames sourceData;
|
||||
mainProgram = "grok";
|
||||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
||||
};
|
||||
})
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl common-updater-scripts
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
version="$(curl -fsSL https://x.ai/cli/stable)"
|
||||
|
||||
currentVersion=$(
|
||||
nix-instantiate --eval --raw -E "with import ./. {}; grok-build.version or (lib.getVersion grok-build)"
|
||||
)
|
||||
|
||||
if [[ "$currentVersion" == "$version" ]]; then
|
||||
echo "package is up-to-date: $version"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
update-source-version grok-build "${version}" || true
|
||||
|
||||
for system in "aarch64-darwin macos-aarch64" "aarch64-linux linux-aarch64" "x86_64-darwin macos-x86_64" "x86_64-linux linux-x86_64"; do
|
||||
# shellcheck disable=SC2086
|
||||
set -- ${system}
|
||||
|
||||
arch="${1}"
|
||||
platform="${2}"
|
||||
|
||||
url="https://x.ai/cli/grok-${version}-${platform}"
|
||||
hash=$(
|
||||
nix --extra-experimental-features nix-command hash convert --hash-algo sha256 "$(
|
||||
nix-prefetch-url "${url}"
|
||||
)"
|
||||
)
|
||||
|
||||
update-source-version grok-build "${version}" "${hash}" --system="${arch}" --ignore-same-version
|
||||
done
|
||||
Reference in New Issue
Block a user