tools/pkgs/fawltydeps/update.sh

33 lines
699 B
Bash
Raw Permalink Normal View History

2023-03-16 01:12:20 +03:00
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nix-prefetch-github gnused jq
function help() {
echo "Regenerates packaging data for the fawltydeps package."
echo "Usage: $0 <rev>"
exit 1
}
if [[ $# -gt 1 || $1 == -* ]]; then
help
fi
set -x
cd "$(dirname "$0")"
version="$1"
set -euo pipefail
if [ -z "$version" ]; then
help
fi
src_hash=$(nix-prefetch-github tweag FawltyDeps --rev "${version}" | jq -r .sha256)
src_hash=$(nix hash to-sri --type sha256 "$src_hash")
sed -i -E -e "s#rev = \".*\"#rev = \"$version\"#" default.nix
sed -i -E -e "s#sha256 = \".*\"#sha256 = \"$src_hash\"#" default.nix
sed -i -E -e "s#version = \".*\"#version = \"$(date +%Y-%m-%d)\"#" default.nix