about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/haskell/haskell-language-server/update.sh
blob: aaccf8b9b9fe21781557fefd25006e501e862aa5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p cabal2nix jq curl
#
# This script will update the haskell-language-server derivation to the latest version using
# cabal2nix.
#
# Note that you should always try building haskell-language-server after updating it here, since
# some of the overrides in pkgs/development/haskell/configuration-nix.nix may
# need to be updated/changed.
#
# Remember to split out different updates into multiple commits

set -eo pipefail

# This is the directory of this update.sh script.
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# ===========================
# HLS
# ===========================

# hls derivation created with cabal2nix.
hls_derivation_file="${script_dir}/default.nix"

# This is the current revision of hls in Nixpkgs.
hls_old_version="$(sed -En 's/.*\bversion = "(.*?)".*/\1/p' "$hls_derivation_file")"

# This is the latest release version of hls on GitHub.
# Get all tag names, filter to the hls ones (no prefix like 'hls-plugin-api-'),
# sort for the latest one and select just that
hls_latest_release=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/haskell/haskell-language-server/tags |
  jq --raw-output 'map(.name) | .[]' |
  grep '^[0-9]' |
  sort --version-sort |
  tail -n1)

# Use this value instead for the very latest revision
# hls_head=(curl --silent "https://api.github.com/repos/haskell/haskell-language-server/commits/master" | jq '.sha' --raw-output)

hls_new_version=$hls_latest_release

echo "Updating haskell-language-server from old version $hls_old_version to new version $hls_new_version."
echo "Running cabal2nix and outputting to ${hls_derivation_file}..."
cabal2nix --revision "$hls_new_version" "https://github.com/haskell/haskell-language-server.git" > "$hls_derivation_file"
cabal2nix --revision "$hls_new_version" --subpath plugins/tactics "https://github.com/haskell/haskell-language-server.git" > "${script_dir}/hls-tactics-plugin.nix"
for plugin in "hls-hlint-plugin" "hls-explicit-imports-plugin" "hls-retrie-plugin" "hls-class-plugin" "hls-eval-plugin"; do
   cabal2nix --revision "$hls_new_version" --subpath plugins/$plugin "https://github.com/haskell/haskell-language-server.git" > "${script_dir}/$plugin.nix"
done

echo "Finished."