darwin.AvailabilityVersions: use mkAppleDerivation

This commit is contained in:
Randy Eckenrode 2024-09-02 19:27:03 -04:00
parent 4624bd7959
commit 78076b3c12
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9
4 changed files with 30 additions and 12 deletions

View File

@ -1,16 +1,26 @@
{
lib,
stdenvNoCC,
appleDerivation',
gnused,
python3,
apple-sdk,
buildPackages,
mkAppleDerivation,
unifdef,
}:
appleDerivation' stdenvNoCC {
nativeBuildInputs = [ unifdef ];
let
inherit (buildPackages) gnused python3;
in
mkAppleDerivation (finalAttrs: {
releaseName = "AvailabilityVersions";
patches = [ ./0001-Support-setting-an-upper-bound-on-versions.patch ];
patches = [
# Add support for setting an upper bound, which is needed by the `gen-headers` script.
# It avoids having pre-process the DSL to remove unwanted versions.
./patches/0001-Support-setting-an-upper-bound-on-versions.patch
];
noCC = true;
nativeBuildInputs = [ unifdef ];
buildPhase = ''
runHook preBuild
@ -33,7 +43,7 @@ appleDerivation' stdenvNoCC {
cp -r availability.dsl templates "$out/share/availability/"
substitute availability "$out/libexec/availability" \
--replace-fail '/usr/bin/env python3' '${lib.getBin python3}/bin/python3' \
--replace-fail '/usr/bin/env python3' '${lib.getExe python3}' \
--replace-fail 'f"{os.path.abspath(os.path.dirname(sys.argv[0]))}/' "\"$out/share/availability/"
chmod a+x "$out/libexec/availability"
@ -61,7 +71,7 @@ appleDerivation' stdenvNoCC {
--preprocess "$out/share/availability/templates/\$header_src" "\$dest/include/\$header"
done
# `__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__` is only defined by clang 17+, so define it for older versions.
# __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ is only defined by clang 17+, so define it for older versions.
${lib.getExe gnused} -E '/#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED/{
i#ifndef __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__
i#define __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__ __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
@ -95,5 +105,9 @@ appleDerivation' stdenvNoCC {
runHook postInstall
'';
meta.mainProgram = "gen-headers";
}
meta = {
description = "Generates Darwin Availability headers";
mainProgram = "gen-headers";
platforms = lib.platforms.unix;
};
})

View File

@ -260,7 +260,7 @@ developerToolsPackages_11_3_1 // macosPackages_11_0_1 // {
inherit (self.adv_cmds) ps locale;
architecture = applePackage "architecture" "osx-10.11.6" "sha256-cUKeMx6mOAxBSRHIdfzsrR65Qv86m7+20XvpKqVfwVI=" {};
AvailabilityVersions = applePackage "AvailabilityVersions" "macos-14.4" "sha256-O9/EOsbK5ZXxh6iDSTwGWWrY5GX/viUwdfG3tdvZwcQ=" {};
AvailabilityVersions = callPackage ./AvailabilityVersions/package.nix { };
bsdmake = applePackage "bsdmake" "dev-tools-3.2.6" "sha256-CW8zP5QZMhWTGp+rhrm8oHE/vSLsRlv1VRAGe1OUDmI=" {};
CarbonHeaders = applePackage "CarbonHeaders" "osx-10.6.2" "sha256-UNaHvxzYzEBnYYuoMLqWUVprZa6Wqn/3XleoSCco050=" {};
CommonCrypto = applePackage "CommonCrypto" "osx-10.12.6" "sha256-FLgODBrfv+XsGaAjddncYAm/BIJJYw6LcwX/z7ncKFM=" {};

View File

@ -1,4 +1,8 @@
{
"AvailabilityVersions": {
"hash": "sha256-O9/EOsbK5ZXxh6iDSTwGWWrY5GX/viUwdfG3tdvZwcQ=",
"version": "140.1"
},
"adv_cmds": {
"hash": "sha256-Ztp8ALWcviEpthoiY8ttWzGI8OcsLzsULjlqe8GIzw8=",
"version": "163"