2021-02-19 19:06:45 +00:00
|
|
|
#!/usr/bin/env nix-shell
|
2023-01-11 07:51:40 +00:00
|
|
|
#!nix-shell -i bash -p curl jq
|
2021-02-19 19:06:45 +00:00
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
usage() {
|
|
|
|
cat <<EOF
|
|
|
|
usage: $0 macos 11.0.1
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$#" != 2 ]; then
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-02-19 19:06:45 +00:00
|
|
|
|
|
|
|
cd $(dirname "$0")
|
|
|
|
|
|
|
|
sdkName="$1-$2"
|
|
|
|
outfile="$sdkName.nix"
|
|
|
|
|
|
|
|
>$outfile echo "# Generated using: ./$(basename "$0") $1 $2
|
|
|
|
|
|
|
|
{ applePackage' }:
|
|
|
|
|
|
|
|
{"
|
|
|
|
|
|
|
|
parse_line() {
|
2023-01-11 07:51:40 +00:00
|
|
|
readarray -t -d$'-' package < <(printf "%s" $2)
|
2021-02-19 19:06:45 +00:00
|
|
|
local pname=${package[0]} version=${package[1]}
|
|
|
|
|
|
|
|
if [ -d $pname ]; then
|
2023-01-11 07:51:40 +00:00
|
|
|
sha256=$(nix-prefetch-url "https://github.com/apple-oss-distributions/$pname/archive/refs/tags/$pname-$version.tar.gz")
|
2021-02-19 19:06:45 +00:00
|
|
|
>>$outfile echo "$pname = applePackage' \"$pname\" \"$version\" \"$sdkName\" \"$sha256\" {};"
|
|
|
|
fi
|
|
|
|
}
|
2023-01-11 07:51:40 +00:00
|
|
|
readarray -s1 -c1 -C parse_line < <(curl -sSL "https://github.com/apple-oss-distributions/distribution-${1//-/_}/raw/${sdkName//./}/release.json" | jq -r ".projects[].tag")
|
2021-02-19 19:06:45 +00:00
|
|
|
|
|
|
|
>>$outfile echo '}'
|