1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p cabal2nix curl jq haskellPackages.cabal2nix-unstable -I nixpkgs=.
4 # This script will update the spago derivation to the latest version using
7 # Note that you should always try building spago after updating it here, since
8 # some of the overrides in pkgs/development/haskell/configuration-nix.nix may
9 # need to be updated/changed.
13 # This is the directory of this update.sh script.
14 script_dir
="$( cd "$
( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
16 # Spago derivation created with cabal2nix.
17 spago_derivation_file
="${script_dir}/spago.nix"
19 # This is the current revision of spago in Nixpkgs.
20 old_version
="$(sed -En 's/.*\bversion = "(.
*?
)".*/\1/p' "$spago_derivation_file")"
22 # This is the latest release version of spago on GitHub.
23 new_version
=$
(curl
--silent "https://api.github.com/repos/purescript/spago/releases" | jq
'.[0].tag_name' --raw-output)
25 echo "Updating spago from old version $old_version to new version $new_version."
26 echo "Running cabal2nix and outputting to ${spago_derivation_file}..."
28 echo "# This has been automatically generated by the script" > "$spago_derivation_file"
29 echo "# ./update.sh. This should not be changed by hand." >> "$spago_derivation_file"
31 cabal2nix
--revision "$new_version" "https://github.com/purescript/spago.git" >> "$spago_derivation_file"
33 # TODO: This should ideally also automatically update the docsSearchVersion
34 # from pkgs/development/haskell/configuration-nix.nix.
37 echo "Finished. Make sure you run the following commands to confirm Spago builds correctly:"
38 echo ' - `nix build -L -f ./. spago`'
39 echo ' - `sudo nix build -L -f ./. spago.passthru.tests --option sandbox relaxed`'