From 7cbc498a0edac3ccfda186fd3312566d78553f49 Mon Sep 17 00:00:00 2001 From: "(cdep)illabout" Date: Fri, 20 Dec 2019 13:25:26 +0900 Subject: [PATCH] spago: add update script for automatically updating to new versions --- .../tools/purescript/spago/update.sh | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 pkgs/development/tools/purescript/spago/update.sh diff --git a/pkgs/development/tools/purescript/spago/update.sh b/pkgs/development/tools/purescript/spago/update.sh new file mode 100755 index 000000000000..df903abd598e --- /dev/null +++ b/pkgs/development/tools/purescript/spago/update.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p cabal2nix curl jq +# +# This script will update the spago derivation to the latest version using +# cabal2nix. +# +# Note that you should always try building spago after updating it here, since +# some of the overrides in pkgs/development/haskell/configuration-nix.nix may +# need to be updated/changed. + +set -eo pipefail + +# This is the directory of this update.sh script. +script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# Spago derivation created with cabal2nix. +spago_derivation_file="${script_dir}/default.nix" + +# This is the current revision of spago in Nixpkgs. +old_version="$(sed -En 's/.*\bversion = "(.*?)".*/\1/p' "$spago_derivation_file")" + +# This is the latest release version of spago on GitHub. +new_version=$(curl --silent "https://api.github.com/repos/spacchetti/spago/releases" | jq '.[0].tag_name' --raw-output) + +echo "Updating spago from old version $old_version to new version $new_version." +echo "Running cabal2nix and outputting to ${spago_derivation_file}..." + +cabal2nix --revision "$new_version" "https://github.com/spacchetti/spago.git" > "$spago_derivation_file" + +echo "Finished."