depot/third_party/nixpkgs/pkgs/by-name/ni/nixfmt-rfc-style/update.sh
Default email 23b612e36f Project import generated by Copybara.
GitOrigin-RevId: ae5c332cbb5827f6b1f02572496b141021de335f
2024-01-25 23:12:00 +09:00

33 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p cabal2nix curl jq
#
# This script will update the nixfmt-rfc-style derivation to the latest version using
# cabal2nix.
set -eo pipefail
# This is the directory of this update.sh script.
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
derivation_file="${script_dir}/generated-package.nix"
date_file="${script_dir}/date.txt"
# This is the latest version of nixfmt-rfc-style branch on GitHub.
new_version=$(curl --silent https://api.github.com/repos/piegamesde/nixfmt/git/refs/heads/rfc101-style | jq '.object.sha' --raw-output)
new_date=$(curl --silent https://api.github.com/repos/piegamesde/nixfmt/git/commits/"$new_version" | jq '.committer.date' --raw-output)
echo "Updating nixfmt-rfc-style to version $new_date."
echo "Running cabal2nix and outputting to ${derivation_file}..."
cat > "$derivation_file" << EOF
# This file has been autogenerate with cabal2nix.
# Update via ./update.sh
EOF
cabal2nix --jailbreak \
"https://github.com/piegamesde/nixfmt/archive/${new_version}.tar.gz" \
>> "$derivation_file"
date --date="$new_date" -I > "$date_file"
echo "Finished."