darwin.mkAppleDerivation: use lib.extendMkDerivation (#453094)

This commit is contained in:
Emily 2025-10-23 00:19:23 +00:00 committed by GitHub
commit 8cf6f340f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 51 additions and 69 deletions

View file

@ -19,8 +19,6 @@ mkAppleDerivation (finalAttrs: {
./patches/0001-Support-setting-an-upper-bound-on-versions.patch ./patches/0001-Support-setting-an-upper-bound-on-versions.patch
]; ];
noCC = true;
nativeBuildInputs = [ unifdef ]; nativeBuildInputs = [ unifdef ];
buildPhase = '' buildPhase = ''

View file

@ -8,45 +8,31 @@ in
fetchFromGitHub, fetchFromGitHub,
meson, meson,
ninja, ninja,
stdenv,
stdenvNoCC,
xcodeProjectCheckHook, xcodeProjectCheckHook,
}: }:
let let
hasBasenamePrefix = prefix: file: lib.hasPrefix prefix (baseNameOf file); hasBasenamePrefix = prefix: file: lib.hasPrefix prefix (baseNameOf file);
in in
lib.makeOverridable ( lib.extendMkDerivation {
attrs: constructDrv = bootstrapStdenv.mkDerivation;
extendDrvArgs =
finalAttrs: args:
assert args ? releaseName;
let let
attrs' = if lib.isFunction attrs then attrs else _: attrs; inherit (args) releaseName;
attrsFixed = lib.fix attrs';
stdenv' =
if attrsFixed.noCC or false then
stdenvNoCC
else if attrsFixed.noBootstrap or false then
stdenv
else
bootstrapStdenv;
in
stdenv'.mkDerivation (
lib.extends (
self: super:
assert super ? releaseName;
let
inherit (super) releaseName;
info = versions.${releaseName}; info = versions.${releaseName};
files = lib.filesystem.listFilesRecursive (lib.path.append ./. releaseName); files = lib.filesystem.listFilesRecursive (lib.path.append ./. releaseName);
mesonFiles = lib.filter (hasBasenamePrefix "meson") files; mesonFiles = lib.filter (hasBasenamePrefix "meson") files;
in in
# You have to have at least `meson.build.in` when using xcodeHash to trigger the Meson # You have to have at least `meson.build.in` when using xcodeHash to trigger the Meson
# build support in `mkAppleDerivation`. # build support in `mkAppleDerivation`.
assert super ? xcodeHash -> lib.length mesonFiles > 0; assert args ? xcodeHash -> lib.length mesonFiles > 0;
{ {
pname = super.pname or releaseName; pname = args.pname or releaseName;
inherit (info) version; inherit (info) version;
src = super.src or fetchFromGitHub { src = args.src or fetchFromGitHub {
owner = "apple-oss-distributions"; owner = "apple-oss-distributions";
repo = releaseName; repo = releaseName;
rev = info.rev or "${releaseName}-${info.version}"; rev = info.rev or "${releaseName}-${info.version}";
@ -62,11 +48,11 @@ lib.makeOverridable (
teams = [ lib.teams.darwin ]; teams = [ lib.teams.darwin ];
platforms = lib.platforms.darwin; platforms = lib.platforms.darwin;
} }
// super.meta or { }; // args.meta or { };
} }
// lib.optionalAttrs (super ? xcodeHash) { // lib.optionalAttrs (args ? xcodeHash) {
postUnpack = postUnpack =
super.postUnpack or "" args.postUnpack or ""
+ lib.concatMapStrings ( + lib.concatMapStrings (
file: file:
if baseNameOf file == "meson.build.in" then if baseNameOf file == "meson.build.in" then
@ -75,16 +61,14 @@ lib.makeOverridable (
"cp ${lib.escapeShellArg "${file}"} \"$sourceRoot/\"${lib.escapeShellArg (baseNameOf file)}\n" "cp ${lib.escapeShellArg "${file}"} \"$sourceRoot/\"${lib.escapeShellArg (baseNameOf file)}\n"
) mesonFiles; ) mesonFiles;
xcodeProject = super.xcodeProject or "${releaseName}.xcodeproj"; xcodeProject = args.xcodeProject or "${releaseName}.xcodeproj";
nativeBuildInputs = super.nativeBuildInputs or [ ] ++ [ nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [
meson meson
ninja ninja
xcodeProjectCheckHook xcodeProjectCheckHook
]; ];
mesonBuildType = "release"; mesonBuildType = "release";
};
} }
) attrs'
)
)