about summary refs log tree commit diff
path: root/pkgs/by-name/jd/jdt-language-server/update.sh
blob: b482db22ee056ce54417c87e1979e33c7f3d9477 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /usr/bin/env nix-shell
#! nix-shell -i bash --pure -p curl cacert libxml2 yq nix jq

set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")"
DRV_DIR="$PWD"

# scrape the downloads page for release info
newver=$(curl -s 'https://download.eclipse.org/jdtls/milestones/' | xmllint --html - --xmlout 2>/dev/null | xq --raw-output '.html.body.main.div.div.div[0].div.table.tr | max_by(.td[3]).td[1].a.["#text"]')

prefix="https://download.eclipse.org/jdtls/milestones/$newver"

filename=$(curl -s "$prefix/latest.txt")
newtimestamp=$(echo $filename | sed "s|^.*-$newver-||;s|\.tar\.gz$||")
newhash="$(nix-hash --to-sri --type sha256 $(nix-prefetch-url "$prefix/$filename"))";

sed -i default.nix \
    -e "/^  version =/ s|\".*\"|\"$newver\"|" \
    -e "/^  timestamp =/ s|\".*\"|\"$newtimestamp\"|" \
    -e "/^    hash =/ s|\".*\"|\"$newhash\"|" \