youki: add systemd build flag (#355607)
[NixPkgs.git] / pkgs / applications / misc / tandoor-recipes / update.sh
blob63021d76f6b7351c8ca1f9b0c01426893dc99608
1 #!/usr/bin/env nix-shell
2 #!nix-shell -I nixpkgs=../../../../ -i bash -p nix wget prefetch-yarn-deps nix-prefetch-github jq
4 # shellcheck shell=bash
6 if [ -n "$GITHUB_TOKEN" ]; then
7 TOKEN_ARGS=(--header "Authorization: token $GITHUB_TOKEN")
8 fi
10 if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
11 echo "Regenerates packaging data for the tandoor-recipes package."
12 echo "Usage: $0 [git release tag]"
13 exit 1
16 version="$1"
18 set -euo pipefail
20 if [ -z "$version" ]; then
21 version="$(wget -O- "${TOKEN_ARGS[@]}" "https://api.github.com/repos/TandoorRecipes/recipes/releases?per_page=1" | jq -r '.[0].tag_name')"
24 package_src="https://raw.githubusercontent.com/TandoorRecipes/recipes/$version"
26 src_hash=$(nix-prefetch-github TandoorRecipes recipes --rev "${version}" | jq -r .hash)
28 tmpdir=$(mktemp -d)
29 trap 'rm -rf "$tmpdir"' EXIT
31 pushd "$tmpdir"
32 wget "${TOKEN_ARGS[@]}" "$package_src/vue/yarn.lock"
33 yarn_hash=$(prefetch-yarn-deps yarn.lock)
34 popd
36 # Use friendlier hashes
37 yarn_hash=$(nix hash to-sri --type sha256 "$yarn_hash")
39 sed -i -E -e "s#version = \".*\"#version = \"$version\"#" common.nix
40 sed -i -E -e "s#hash = \".*\"#hash = \"$src_hash\"#" common.nix
41 sed -i -E -e "s#yarnHash = \".*\"#yarnHash = \"$yarn_hash\"#" common.nix