1#!/usr/bin/env nix-shell
2#!nix-shell -i bash -p cabal2nix curl jq
3
4set -euo pipefail
5
6# This is the directory of this update.sh script.
7script_dir="$(dirname "${BASH_SOURCE[0]}")"
8derivation_file="${script_dir}/generated-package.nix"
9latest_version="$(curl --silent 'https://api.github.com/repos/gren-lang/compiler/releases/latest' | jq --raw-output '.tag_name')"
10
11echo "Updating gren to version ${latest_version}."
12echo "Running cabal2nix and outputting to ${derivation_file}..."
13
14cat > "${derivation_file}" << EOF
15# This file has been autogenerated with cabal2nix.
16# Update via ./update.sh
17EOF
18
19cabal2nix 'https://github.com/gren-lang/compiler.git' --revision "${latest_version}" --jailbreak >> "${derivation_file}"
20nixfmt "${derivation_file}"
21
22echo 'Finished.'