···6cd "$(dirname "${BASH_SOURCE[0]}")"
7tmpfile="$(mktemp --suffix=.nix)"
8009info() { echo "[INFO] $*"; }
1011echo_file() { echo "$@" >> "$tmpfile"; }
···43 [js-installable-svm]="https://github.com/graalvm/graaljs/releases/download/vm-${new_version}/js-installable-svm-java@platform@-${new_version}.jar"
44 [llvm-installable-svm]="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/llvm-installable-svm-java@platform@-${new_version}.jar"
45 [native-image-installable-svm]="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/native-image-installable-svm-java@platform@-${new_version}.jar"
046 [python-installable-svm]="https://github.com/graalvm/graalpython/releases/download/vm-${new_version}/python-installable-svm-java@platform@-${new_version}.jar"
47 [ruby-installable-svm]="https://github.com/oracle/truffleruby/releases/download/vm-${new_version}/ruby-installable-svm-java@platform@-${new_version}.jar"
48 [wasm-installable-svm]="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/wasm-installable-svm-java@platform@-${new_version}.jar"
···59 "17-darwin-amd64"
60)
6162-info "Generating hashes.nix file for 'graalvm-ce' $new_version. This will take a while..."
6364# Indentation of `echo_file` function is on purpose to make it easier to visualize the output
65echo_file "# Generated by $0 script"
···68 url="${products_urls["${product}"]}"
69echo_file " \"$product\" = {"
70 for platform in "${platforms[@]}"; do
71- # Reuse cache as long the version is the same
72- if [[ "$current_version" == "$new_version" ]]; then
73- previous_hash="$(nix-instantiate --eval "$hashes_nix" -A "$product.$platform.sha256" --json | jq -r || true)"
00074 else
75- previous_hash=""
76 fi
77- # Lack of quoting in $previous_hash is proposital
78- if hash="$(nix-prefetch-url "${url//@platform@/$platform}" $previous_hash)"; then
79echo_file " \"$platform\" = {"
80echo_file " sha256 = \"$hash\";"
81echo_file " url = \"${url//@platform@/${platform}}\";"
···6cd "$(dirname "${BASH_SOURCE[0]}")"
7tmpfile="$(mktemp --suffix=.nix)"
89+trap 'rm -rf "$tmpfile"' EXIT
10+11info() { echo "[INFO] $*"; }
1213echo_file() { echo "$@" >> "$tmpfile"; }
···45 [js-installable-svm]="https://github.com/graalvm/graaljs/releases/download/vm-${new_version}/js-installable-svm-java@platform@-${new_version}.jar"
46 [llvm-installable-svm]="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/llvm-installable-svm-java@platform@-${new_version}.jar"
47 [native-image-installable-svm]="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/native-image-installable-svm-java@platform@-${new_version}.jar"
48+ [nodejs-installable-svm]="https://github.com/graalvm/graaljs/releases/download/vm-${new_version}/nodejs-installable-svm-java@platform@-${new_version}.jar"
49 [python-installable-svm]="https://github.com/graalvm/graalpython/releases/download/vm-${new_version}/python-installable-svm-java@platform@-${new_version}.jar"
50 [ruby-installable-svm]="https://github.com/oracle/truffleruby/releases/download/vm-${new_version}/ruby-installable-svm-java@platform@-${new_version}.jar"
51 [wasm-installable-svm]="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/wasm-installable-svm-java@platform@-${new_version}.jar"
···62 "17-darwin-amd64"
63)
6465+info "Generating '$hashes_nix' file for 'graalvm-ce' $new_version. This will take a while..."
6667# Indentation of `echo_file` function is on purpose to make it easier to visualize the output
68echo_file "# Generated by $0 script"
···71 url="${products_urls["${product}"]}"
72echo_file " \"$product\" = {"
73 for platform in "${platforms[@]}"; do
74+ args=("${url//@platform@/$platform}")
75+ # Get current hashes to skip derivations already in /nix/store to reuse cache when the version is the same
76+ # e.g.: when adding a new product and running this script with FORCE=1
77+ if [[ "$current_version" == "$new_version" ]] && \
78+ previous_hash="$(nix-instantiate --eval "$hashes_nix" -A "$product.$platform.sha256" --json | jq -r)"; then
79+ args+=("$previous_hash" "--type" "sha256")
80 else
81+ info "Hash in '$product' for '$platform' not found. Re-downloading it..."
82 fi
83+ if hash="$(nix-prefetch-url "${args[@]}")"; then
084echo_file " \"$platform\" = {"
85echo_file " sha256 = \"$hash\";"
86echo_file " url = \"${url//@platform@/${platform}}\";"