Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#!/usr/bin/env bash
2
3set -eu -o pipefail
4
5if [[ $# -lt 1 ]]; then
6 echo "$0: version" >&2
7 exit 1
8fi
9
10VERSION="$1"
11
12declare -A SYSTEMS HASHES
13SYSTEMS=(
14 [i686-linux]=linux-ia32
15 [x86_64-linux]=linux-x64
16 [armv7l-linux]=linux-armv7l
17 [aarch64-linux]=linux-arm64
18 [x86_64-darwin]=darwin-x64
19 [aarch64-darwin]=darwin-arm64
20)
21
22hashfile="$(nix-prefetch-url --print-path "https://github.com/electron/electron/releases/download/v${VERSION}/SHASUMS256.txt" | tail -n1)"
23headers="$(nix-prefetch-url "https://artifacts.electronjs.org/headers/dist/v${VERSION}/node-v${VERSION}-headers.tar.gz")"
24
25# Entry similar to the following goes in default.nix:
26
27echo " electron_${VERSION%%.*}-bin = mkElectron \"${VERSION}\" {"
28
29for S in "${!SYSTEMS[@]}"; do
30 hash="$(grep " *electron-v${VERSION}-${SYSTEMS[$S]}.zip$" "$hashfile"|cut -f1 -d' ' || :)"
31 if [[ -n $hash ]]; then
32 echo " $S = \"$hash\";"
33 fi
34done
35
36echo " headers = \"$headers\";"
37
38echo " };"