#!/usr/bin/env bash set -eo pipefail # set -x # TODO: Update pobfrontend as well? 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 =" packages/pob.nix| cut -d":" -f1) rev_line_data=$(head -n1 <<< "$rev_line_numbers") sed -i "${rev_line_data}s/.*/ rev = $rev;/" packages/pob.nix hash_line_numbers=$(grep -Fn "hash =" packages/pob.nix| cut -d":" -f1) hash_line_data=$(head -n1 <<< "$hash_line_numbers") sed -i "${hash_line_data}s/.*/ hash = $hash;/" packages/pob.nix nixfmt packages/pob.nix