depot/third_party/nixpkgs/pkgs/development/compilers/nim/update.sh
Default email 472aeafc57 Project import generated by Copybara.
GitOrigin-RevId: c31898adf5a8ed202ce5bea9f347b1c6871f32d1
2024-10-04 18:56:33 +02:00

25 lines
616 B
Bash

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash nix-update curl coreutils jq
set -ex
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
curl_github() {
curl ${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} "$@"
}
case "$UPDATE_NIX_ATTR_PATH" in
nim)
latestTag=$(curl_github https://api.github.com/repos/nim-lang/Nim/releases/latest | jq -r ".tag_name")
latestVersion="$(expr "$latestTag" : 'v\(.*\)')"
echo "Updating Nim"
nix-update --version "$latestVersion" \
--override-filename "$SCRIPT_DIR/default.nix" \
nim
*)
echo "Unknown attr path $UPDATE_NIX_ATTR_PATH"
;;
esac