nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1#!/usr/bin/env nix-shell
2#! nix-shell -i bash --pure -p curl cacert libxml2 yq nix jq
3#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/3c7487575d9445185249a159046cc02ff364bff8.tar.gz
4# ^
5# |
6# nixos-unstable ~ 2023-07-06 -----------------/
7
8set -o errexit
9set -o nounset
10
11# scrape the downloads page for release info
12
13curl -s -o eclipse-dl.html https://download.eclipse.org/eclipse/downloads/
14trap "rm eclipse-dl.html" EXIT
15
16dlquery() {
17 q=$1
18 xmllint --html eclipse-dl.html --xmlout 2>/dev/null | xq -r ".html.body.main.div.table[3].tr[1].td[0].a${q}";
19}
20
21# extract release info from download page HTML
22
23platform_major=$(dlquery '."#text" | split(".") | .[0]' -r);
24platform_minor=$(dlquery '."#text" | split(".") | .[1]' -r);
25
26year=$(dlquery '."@href" | split("/") | .[] | select(. | startswith("R")) | split("-") | .[2] | .[0:4]')
27buildmonth=$(dlquery '."@href" | split("/") | .[] | select(. | startswith("R")) | split("-") | .[2] | .[4:6]')
28builddaytime=$(dlquery '."@href" | split("/") | .[] | select(. | startswith("R")) | split("-") | .[2] | .[6:12]')
29timestamp="${year}${buildmonth}${builddaytime}";
30
31# account for possible release-month vs. build-month mismatches
32
33month=$buildmonth;
34case "$buildmonth" in
35 '02'|'04') month='03' ;;
36 '05'|'07') month='06' ;;
37 '08'|'10') month='09' ;;
38 '11'|'01') month='12' ;;
39esac
40
41cat <<EOF
42
43paste the following into the 'let' block near the top of pkgs/applications/editors/eclipse/default.nix:
44
45 platform_major = "${platform_major}";
46 platform_minor = "${platform_minor}";
47 year = "${year}";
48 month = "${month}"; #release month
49 buildmonth = "${buildmonth}"; #sometimes differs from release month
50 timestamp = "\${year}\${buildmonth}${builddaytime}";
51EOF
52
53# strip existing download hashes
54
55sed -i 's/64 = ".*";$/64 = "";/g' pkgs/applications/editors/eclipse/default.nix
56
57# prefetch new download hashes
58
59echo;
60echo "paste the following url + hash blocks into pkgs/applications/editors/eclipse/default.nix:";
61
62for u in $(grep 'url = ' pkgs/applications/editors/eclipse/default.nix | grep arch | cut -d '"' -f 2 | sed 's/&/\\&/g'); do
63 echo;
64 echo " url = \"${u}\";";
65 echo " hash = {";
66 for arch in x86_64 aarch64; do
67 us=$(eval echo "$u");
68 h=$(nix store prefetch-file --json "$us" | jq -r .hash);
69 echo " $arch = \"${h}\";";
70 done
71 echo ' }.${arch};';
72done