darwin.mkAppleDerivation: migrate to use darwin.sourceRelease

This commit is contained in:
Randy Eckenrode
2026-04-18 00:39:05 -04:00
parent b00e2f3bc5
commit e3e8c0c2cf
3 changed files with 4 additions and 211 deletions
@@ -1,13 +1,9 @@
let
versions = builtins.fromJSON (builtins.readFile ./versions.json);
in
{
lib,
bootstrapStdenv,
fetchFromGitHub,
meson,
ninja,
sourceRelease,
xcodeProjectCheckHook,
}:
@@ -31,7 +27,7 @@ lib.extendMkDerivation {
assert args ? releaseName;
let
inherit (args) releaseName;
info = versions.${releaseName};
releaseSrc = sourceRelease releaseName;
files = lib.filesystem.listFilesRecursive (prependShardPath releaseName);
mesonFiles = lib.filter (hasBasenamePrefix "meson") files;
in
@@ -40,14 +36,9 @@ lib.extendMkDerivation {
assert args ? xcodeHash -> lib.length mesonFiles > 0;
{
pname = args.pname or releaseName;
inherit (info) version;
inherit (releaseSrc) version;
src = args.src or fetchFromGitHub {
owner = "apple-oss-distributions";
repo = releaseName;
rev = info.rev or "${releaseName}-${info.version}";
inherit (info) hash;
};
src = args.src or releaseSrc;
strictDeps = true;
__structuredAttrs = true;
@@ -1,80 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils curl git gnutar jq moreutils nix
set -eu -o pipefail
if [ ! -v 1 ]; then
echo "usage: lock-sdk-deps.sh <macOS version> <Packages>" >&2
echo " <macOS version> Decimal-separated version number." >&2
echo " Must correspond to a tag in https://github.com/apple-oss-distributions/distribution-macOS" >&2
exit 1
fi
pkgdir=$(dirname "$(realpath "$0")")
lockfile=$pkgdir/versions.json
if [ -e "$lockfile" ]; then
echo '{}' > "$lockfile"
fi
workdir=$(mktemp -d)
trap 'rm -rf -- "$workdir"' EXIT
sdkVersion=$1; shift
tag="macos-${sdkVersion//.}"
declare -A ignoredPackages=(
[libsbuf]=1
[locale]=1
[mkAppleDerivation]=1
[update-source-releases.sh]=1
[versions.json]=1
)
readarray -t packages < <(
for file in "$pkgdir"/*; do
pkg=$(basename "$file" ".nix")
test ! "${ignoredPackages[$pkg]-}" && echo "$pkg"
done
)
echo "Locking versions for macOS $sdkVersion using tag '$tag'..."
pushd "$workdir" > /dev/null
git clone --branch "$tag" https://github.com/apple-oss-distributions/distribution-macOS.git &> /dev/null
cd distribution-macOS
for package in "${packages[@]}"; do
# If the tag exists in `release.json`, use that as an optimization to avoid downloading unnecessarily from Github.
packageTag=$(jq -r --arg package "$package" '.projects[] | select(.project == $package) | .tag' release.json)
packageCommit=$(git ls-tree -d HEAD "$package" | awk '{print $3}')
if [ ! -d "$package" ]; then
packageCommit=HEAD
fi
# However, sometimes it doesnt exist. In that case, fall back to cloning the repo and check manually
# which tag corresponds to the commit from the submodule.
if [ -z "$packageTag" ]; then
git clone --no-checkout "https://github.com/apple-oss-distributions/$package.git" ../source &> /dev/null
pushd ../source > /dev/null
packageTag=$(git tag --points-at "$packageCommit")
popd > /dev/null
rm -rf ../source
fi
packageVersion=${packageTag##"$package"-}
curl -OL "https://github.com/apple-oss-distributions/$package/archive/$packageTag.tar.gz" &> /dev/null
tar axf "$packageTag.tar.gz"
packageHash=$(nix --extra-experimental-features nix-command hash path "$package-$packageTag")
pkgsjson="{\"$package\": {\"version\": \"$packageVersion\", \"hash\": \"$packageHash\"}}"
echo " - Locking $package to version $packageVersion with hash '$packageHash'"
jq --argjson pkg "$pkgsjson" -S '. * $pkg' "$lockfile" | sponge "$lockfile"
done
popd > /dev/null
@@ -1,118 +0,0 @@
{
"AvailabilityVersions": {
"hash": "sha256-eQ46qHk4AuHA+hRZq1IG2UtvZr/X2vtlOvi6hnG+FyA=",
"version": "151"
},
"Csu": {
"hash": "sha256-l8RI8aiin7ovZuoDh54thDmd/b502w+dtjN5ZoISZBg=",
"version": "88"
},
"ICU": {
"hash": "sha256-dIgrTjHcQm8dy2Ku5wNIHuPjHfoV+48TM0PNDDn6ZPk=",
"version": "76104.4"
},
"IOKitTools": {
"hash": "sha256-Oknsvzn4nv77WU7f0WPS446iwR2BM2q4iw46r/qctAE=",
"version": "125"
},
"PowerManagement": {
"hash": "sha256-ssg655SPT7gWnJWDaxambMKCopr+vLPYERW0IMKT0T8=",
"version": "1754.140.4"
},
"adv_cmds": {
"hash": "sha256-O+SB8sj3yqPv7GEBQQgvq+Y7kQRZI/i/UVa17J/OhZM=",
"version": "235"
},
"basic_cmds": {
"hash": "sha256-RQve2GqS9ke9hd8kupRMgoOKalTS229asi5tBGrBmS8=",
"version": "70"
},
"bootstrap_cmds": {
"hash": "sha256-6JG0sysgqLlgcpIOXfN+F0/gxpIIHZZ5et3gmDBoBGQ=",
"version": "138"
},
"copyfile": {
"hash": "sha256-hIHlY0prIFY0j8z0Hvlv2psrwLj41jYfKBM0KutLxew=",
"version": "224"
},
"developer_cmds": {
"hash": "sha256-jgQUjN9zmqi0/7XpqzbRsJjZIYeMrxXT1Zf3qi7+o+8=",
"version": "83"
},
"diskdev_cmds": {
"hash": "sha256-TD/sJkzIquTgq1zP/B7eBArxeTcp1Lqa8e8cJ1jnkHU=",
"version": "737.140.4"
},
"doc_cmds": {
"hash": "sha256-nnwKXKKjgJXcLCArD38Dme2L1WyR1U0rwn7zI+NCftw=",
"version": "69"
},
"dyld": {
"hash": "sha256-pbpSD5OeSMOcMJFAd7kyLINPROjqsafsCSphVGyIPyg=",
"version": "1286.10"
},
"file_cmds": {
"hash": "sha256-Rf/XA6uEaj7Wps2s8Oc/OhQVBjz8XiqJlj+cxjiQfQU=",
"version": "457.140.3"
},
"libffi": {
"hash": "sha256-xHefZVsZg9kUXV0t/HLdjPkkD/hn/4bvdRVJ4PsQLeM=",
"version": "40"
},
"libiconv": {
"hash": "sha256-50DC6LePtvdAh9FLa/esiwCUmYDxKofN6hCiv9+dmgQ=",
"version": "109.100.2"
},
"libpcap": {
"hash": "sha256-DqINoombdui5N6lNHcZ07c7LrVum4f8fFK89ymdCd0c=",
"version": "140"
},
"libresolv": {
"hash": "sha256-GtPVlL1mD58um5hOFd3HQKQ7pqutBe9jZKgQw8pOkPE=",
"version": "91"
},
"libutil": {
"hash": "sha256-tUsl22Z0HUVSkSoohFXkhicNFCW+RARvpTS0q6yaQFk=",
"version": "72"
},
"mail_cmds": {
"hash": "sha256-ET1nga9nwgBtN7fuvsPs1yqe5OhQ62PVl7LxqbsAPqU=",
"version": "38.0.1"
},
"misc_cmds": {
"hash": "sha256-04uBS16nNrg73Fqh4Obev7nQDjTTlY4f5+pEv3i0FIU=",
"version": "45"
},
"network_cmds": {
"hash": "sha256-sfZX6aA8mspfRKARIYFXX+bmlLHDoi485HQOvbRNP1Y=",
"version": "705.100.5"
},
"patch_cmds": {
"hash": "sha256-fDY2NOT3DnU5pm06cHSs+JJcA/EFP8Lxjg7sErUerJ0=",
"version": "72"
},
"remote_cmds": {
"hash": "sha256-8c/NgQZ+K6jJ3aoYK78/BsEkM1gmRS+9z0437+SvcCw=",
"version": "306"
},
"removefile": {
"hash": "sha256-Z5UD0mk/s80CQB0PZWDzSl2JWXmnVmwUvlNb28+hR3k=",
"version": "81"
},
"shell_cmds": {
"hash": "sha256-hoMssbZCrmzyJTgEAzOS4L7DhY9z/yXIcvHRhL6W5qc=",
"version": "326"
},
"system_cmds": {
"hash": "sha256-mEo+v0m+aP42XHHwibGKPkT55JFYLTOD5YT5IYQ8Hr0=",
"version": "1026.140.2"
},
"text_cmds": {
"hash": "sha256-5BBH/v1mJpExz65VDX6oh3dFCz49E+JMqJxkO96Y/xo=",
"version": "195"
},
"top": {
"hash": "sha256-e+k/jE49BMZZ24ge9JCa2ct5f1og6ewWb6U5ZMWdIEc=",
"version": "139.40.2"
}
}