Since 1.8, graphite has started relying on binary packages prebuilt per host platform, kind of like obsidian. Therefore, to support newer versions of graphite, I've altered the package definition to download those binary packages directly (one for each platform). On Linux we need a FHS environment wrapper, which makes the code a bit more complex. I've taken the liberty of also adding a version check to the package.
35 lines
968 B
Bash
Executable File
35 lines
968 B
Bash
Executable File
#! /usr/bin/env nix-shell
|
|
#! nix-shell -i bash -p gnused nix nodejs
|
|
|
|
set -euo pipefail
|
|
pushd "$(dirname "${BASH_SOURCE[0]}")"
|
|
|
|
version=$(npm view @withgraphite/graphite-cli version)
|
|
|
|
if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
|
|
echo "Already up to date!"
|
|
exit 0
|
|
fi
|
|
|
|
sed -i 's#version = "[^"]*"#version = "'"$version"'"#' package.nix
|
|
|
|
tmpdir=$(mktemp -d)
|
|
trap 'rm -rf "$tmpdir"' EXIT
|
|
|
|
for platform in linux-x64 linux-arm64 darwin-x64 darwin-arm64; do
|
|
(
|
|
url="https://registry.npmjs.org/@withgraphite/graphite-cli-${platform}/-/graphite-cli-${platform}-${version}.tgz"
|
|
sha256=$(nix-prefetch-url "$url")
|
|
nix-hash --to-sri --type sha256 "$sha256" > "$tmpdir/$platform"
|
|
) &
|
|
done
|
|
wait
|
|
|
|
for platform in linux-x64 linux-arm64 darwin-x64 darwin-arm64; do
|
|
hash=$(cat "$tmpdir/$platform")
|
|
# Each platform hash appears only once in the file
|
|
sed -i "/${platform}/s#\"sha256-[^\"]*\"#\"${hash}\"#" package.nix
|
|
done
|
|
|
|
popd
|