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
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
27 cabal2nix
--jailbreak \
28 "https://github.com/nixos/nixfmt/archive/${new_version}.tar.gz" \
31 date --date="$new_date" -I > "$date_file"