54 lines
1.5 KiB
Bash
Executable file
54 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/env -S nix shell nixpkgs#coreutils nixpkgs#bundix nixpkgs#nix-prefetch-github nixpkgs#jq unstable#yarn-berry_4.yarn-berry-fetcher nixpkgs#git -c bash
|
|
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
echo "Retrieving latest TheEssem/mastodon commit..."
|
|
commit_json="$(curl -SsL 'https://api.github.com/repos/TheEssem/mastodon/branches/main')"
|
|
rev="$(jq -r '.commit.sha' <<<"$commit_json")"
|
|
echo "Latest commit is $rev."
|
|
|
|
echo
|
|
echo "Prefetching TheEssem/mastodon source via nix-prefetch-github..."
|
|
prefetch_json="$(nix-prefetch-github TheEssem mastodon --rev "$rev")"
|
|
hash="$(jq -r '.hash' <<<"$prefetch_json")"
|
|
echo "Source hash is $hash."
|
|
|
|
echo
|
|
echo "Cloning source into tempdir..."
|
|
tmpdir="$(mktemp -d)"
|
|
trap 'rm -rf "$tmpdir"' EXIT
|
|
|
|
git clone --quiet --depth 1 --branch main https://github.com/TheEssem/mastodon.git "$tmpdir"
|
|
pushd "$tmpdir" > /dev/null
|
|
git checkout "$rev"
|
|
popd > /dev/null
|
|
|
|
echo
|
|
echo "Generating gemset.nix..."
|
|
rm -f gemset.nix
|
|
bundix --quiet --lockfile "$tmpdir/Gemfile.lock" --gemfile "$tmpdir/Gemfile"
|
|
|
|
echo
|
|
echo "Generating missing-hashes.json for yarn..."
|
|
rm -f missing-hashes.json
|
|
yarn-berry-fetcher missing-hashes "$tmpdir/yarn.lock" > missing-hashes.json 2>/dev/null
|
|
|
|
echo
|
|
echo "Prefetching yarn deps..."
|
|
yarn_hash="$(yarn-berry-fetcher prefetch "$tmpdir/yarn.lock" ./missing-hashes.json 2>/dev/null)"
|
|
|
|
echo
|
|
echo "Generating version_data.nix..."
|
|
cat > version_data.nix <<EOF
|
|
# This file was generated by update.sh.
|
|
{
|
|
rev = "$rev";
|
|
hash = "$hash";
|
|
yarnHash = "$yarn_hash";
|
|
}
|
|
EOF
|
|
|
|
echo
|
|
echo "Done."
|