nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 31 lines 1.0 kB view raw
1#!/usr/bin/env nix-shell 2#! nix-shell -i bash -p nix jq gnused curl nix-prefetch-git cargo 3 4set -eu -o pipefail 5 6package_dir="$(dirname "${BASH_SOURCE[0]}")" 7 8echo "Fetching latest version" 9version=$(curl -sfL ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} https://api.github.com/repos/rust-lang/measureme/releases/latest | jq -r '.tag_name') 10 11echo "Latest version is $version" 12if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then 13 echo "Already up to date!" 14 exit 0 15fi 16 17echo "Fetching source hash" 18hash="$(nix-prefetch-git https://github.com/rust-lang/measureme.git --quiet --rev "refs/tags/$version" | jq -r '.hash')" 19 20tmp=$(mktemp -d) 21trap "rm -rf $tmp" EXIT 22 23git clone --depth 1 --branch "$version" https://github.com/rust-lang/measureme.git "$tmp" 24pushd "$tmp" 25echo "Generating Cargo.lock" 26cargo update 27cp "Cargo.lock" "$package_dir/Cargo.lock" 28popd 29 30sed -i "s#hash = \".*\";#hash = \"$hash\";#g" "$package_dir/package.nix" 31sed -i "s#version = \".*\";#version = \"$version\";#g" "$package_dir/package.nix"