feat: add openshell package
All checks were successful
Update Nix Packages with nix-update / nix-update (push) Successful in 35m25s
All checks were successful
Update Nix Packages with nix-update / nix-update (push) Successful in 35m25s
This commit is contained in:
52
pkgs/openshell/update.sh
Executable file
52
pkgs/openshell/update.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Update openshell sources.json with the latest release from GitHub.
|
||||
# Usage: ./update.sh
|
||||
# Called automatically by: nix-update --update-script openshell
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SOURCES_FILE="$SCRIPT_DIR/sources.json"
|
||||
|
||||
# Map Nix system -> GitHub release asset name
|
||||
declare -A SYSTEMS=(
|
||||
["x86_64-linux"]="openshell-x86_64-unknown-linux-musl.tar.gz"
|
||||
["aarch64-linux"]="openshell-aarch64-unknown-linux-musl.tar.gz"
|
||||
["aarch64-darwin"]="openshell-aarch64-apple-darwin.tar.gz"
|
||||
)
|
||||
|
||||
echo "Fetching latest openshell release..."
|
||||
LATEST=$(curl -fsSL "https://api.github.com/repos/NVIDIA/OpenShell/releases/latest")
|
||||
VERSION=$(echo "$LATEST" | jq -r '.tag_name')
|
||||
echo "Latest version: $VERSION"
|
||||
|
||||
CURRENT_VERSION=$(jq -r '.version' "$SOURCES_FILE")
|
||||
if [[ "$VERSION" == "$CURRENT_VERSION" ]]; then
|
||||
echo "Already at latest version $VERSION, nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
NEW_SOURCES="{}"
|
||||
|
||||
for NIX_SYSTEM in "${!SYSTEMS[@]}"; do
|
||||
ASSET_NAME="${SYSTEMS[$NIX_SYSTEM]}"
|
||||
URL="https://github.com/NVIDIA/OpenShell/releases/download/${VERSION}/${ASSET_NAME}"
|
||||
|
||||
echo "Fetching hash for $NIX_SYSTEM ($URL)..."
|
||||
HASH=$(nix-prefetch-url --type sha256 "$URL" 2>/dev/null)
|
||||
SRI=$(nix hash to-sri --type sha256 "$HASH")
|
||||
|
||||
NEW_SOURCES=$(echo "$NEW_SOURCES" | jq \
|
||||
--arg sys "$NIX_SYSTEM" \
|
||||
--arg url "$URL" \
|
||||
--arg hash "$SRI" \
|
||||
'. + {($sys): {url: $url, hash: $hash}}')
|
||||
done
|
||||
|
||||
jq -n \
|
||||
--arg version "$VERSION" \
|
||||
--argjson sources "$NEW_SOURCES" \
|
||||
'{"version": $version, "sources": $sources}' \
|
||||
> "$SOURCES_FILE"
|
||||
|
||||
echo "Updated $SOURCES_FILE to $VERSION"
|
||||
Reference in New Issue
Block a user