#!/usr/bin/env nix-shell #!nix-shell -i bash -p git nix jq coreutils gnugrep gnused curl common-updater-scripts set -euo pipefail nixpkgs="$(git rev-parse --show-toplevel || (printf 'Could not find root of nixpkgs repo\nAre we running from within the nixpkgs git repo?\n' >&2; exit 1))" stripwhitespace() { sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' } narhash() { nix --extra-experimental-features nix-command store prefetch-file --json "$1" | jq -r .hash } nixeval() { nix --extra-experimental-features nix-command eval --json --impure -f "$nixpkgs" "$1" | jq -r . } vendorhash() { (nix --extra-experimental-features nix-command build --no-link -f "$nixpkgs" --no-link "$1" 2>&1 >/dev/null | tail -n3 | grep -F got: | cut -d: -f2- | stripwhitespace) 2>/dev/null || true } findpath() { path="$(nix --extra-experimental-features nix-command eval --json --impure -f "$nixpkgs" "$1.meta.position" | jq -r . | cut -d: -f1)" outpath="$(nix --extra-experimental-features nix-command eval --json --impure --expr "builtins.fetchGit \"$nixpkgs\"")" if [ -n "$outpath" ]; then path="${path/$(echo "$outpath" | jq -r .)/$nixpkgs}" fi echo "$path" } getvar() { echo "$2" | grep -F "$1" | sed -e 's/:=/:/g' | cut -d: -f2- | stripwhitespace } attr="${UPDATE_NIX_ATTR_PATH:-curl-impersonate}" version="$(curl -sSL "https://api.github.com/repos/lwthiker/curl-impersonate/releases/latest" | jq -r .tag_name | sed -e 's/^v//')" pkgpath="$(findpath "$attr")" updated="$(cd "$nixpkgs" && update-source-version "$attr" "$version" --file="$pkgpath" --print-changes | jq -r length)" if [ "$updated" -eq 0 ]; then echo 'update.sh: Package version not updated, nothing to do.' exit 0 fi vars="$(curl -sSL "https://github.com/lwthiker/curl-impersonate/raw/v$version/Makefile.in" | grep '^ *[^ ]*_\(VERSION\|URL\|COMMIT\) *:=')" cat >"$(dirname "$pkgpath")"/deps.nix <