about summary refs log tree commit diff
path: root/pkgs/by-name/ni/nixfmt-rfc-style/update.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/ni/nixfmt-rfc-style/update.sh')
-rwxr-xr-xpkgs/by-name/ni/nixfmt-rfc-style/update.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/pkgs/by-name/ni/nixfmt-rfc-style/update.sh b/pkgs/by-name/ni/nixfmt-rfc-style/update.sh
new file mode 100755
index 0000000000000..c70a6e88e7884
--- /dev/null
+++ b/pkgs/by-name/ni/nixfmt-rfc-style/update.sh
@@ -0,0 +1,33 @@
+#!/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."