base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / ni / nixfmt-rfc-style / update.sh
blob9213c7396452449948245394b997b917844e0bac
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p cabal2nix curl jq
4 # This script will update the nixfmt-rfc-style derivation to the latest version using
5 # cabal2nix.
7 set -eo pipefail
9 # This is the directory of this update.sh script.
10 script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
12 derivation_file="${script_dir}/generated-package.nix"
13 date_file="${script_dir}/date.txt"
15 # This is the latest version of nixfmt-rfc-style branch on GitHub.
16 new_version=$(curl --silent https://api.github.com/repos/nixos/nixfmt/git/refs/heads/master | jq '.object.sha' --raw-output)
17 new_date=$(curl --silent https://api.github.com/repos/nixos/nixfmt/git/commits/"$new_version" | jq '.committer.date' --raw-output)
19 echo "Updating nixfmt-rfc-style to version $new_date."
20 echo "Running cabal2nix and outputting to ${derivation_file}..."
22 cat > "$derivation_file" << EOF
23 # This file has been autogenerate with cabal2nix.
24 # Update via ./update.sh
25 EOF
27 cabal2nix --jailbreak \
28 "https://github.com/nixos/nixfmt/archive/${new_version}.tar.gz" \
29 >> "$derivation_file"
31 date --date="$new_date" -I > "$date_file"
33 echo "Finished."