nix-packages/scripts/update-pob.sh
2024-07-21 02:41:47 +02:00

29 lines
909 B
Bash
Executable File

#!/usr/bin/env bash
set -eo pipefail
# set -x
# TODO: Update pobfrontend as well?
POB_NIX_FILE="pkgs/path-of-building-beta/default.nix"
if [ -z "$1" ]; then
nurl_output=$(nurl -j https://github.com/PathOfBuildingCommunity/PathOfBuilding 2>/dev/null)
rev=$(jq '.args.rev' <<< "$nurl_output")
else
nurl_output=$(nurl -j https://github.com/PathOfBuildingCommunity/PathOfBuilding "$1" 2>/dev/null)
fi
hash=$(jq '.args.hash' <<< "$nurl_output" | sed 's/\//\\\//g')
echo "Updating pob to $rev"
# Find lines to replace
rev_line_numbers=$(grep -Fn "rev =" $POB_NIX_FILE| cut -d":" -f1)
rev_line_data=$(head -n1 <<< "$rev_line_numbers")
sed -i "${rev_line_data}s/.*/ rev = $rev;/" $POB_NIX_FILE
hash_line_numbers=$(grep -Fn "hash =" $POB_NIX_FILE| cut -d":" -f1)
hash_line_data=$(head -n1 <<< "$hash_line_numbers")
sed -i "${hash_line_data}s/.*/ hash = $hash;/" $POB_NIX_FILE
nixfmt $POB_NIX_FILE