Unverified Commit 8cf6f340 authored by Emily's avatar Emily Committed by GitHub
Browse files

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

parents 22bb9b30 a7f89aca
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ mkAppleDerivation (finalAttrs: {
    ./patches/0001-Support-setting-an-upper-bound-on-versions.patch
  ];

  noCC = true;

  nativeBuildInputs = [ unifdef ];

  buildPhase = ''
+51 −67
Original line number Diff line number Diff line
@@ -8,45 +8,31 @@ in
  fetchFromGitHub,
  meson,
  ninja,
  stdenv,
  stdenvNoCC,
  xcodeProjectCheckHook,
}:

let
  hasBasenamePrefix = prefix: file: lib.hasPrefix prefix (baseNameOf file);
in
lib.makeOverridable (
  attrs:
lib.extendMkDerivation {
  constructDrv = bootstrapStdenv.mkDerivation;
  extendDrvArgs =
    finalAttrs: args:
    assert args ? releaseName;
    let
    attrs' = if lib.isFunction attrs then attrs else _: attrs;
    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;
      inherit (args) releaseName;
      info = versions.${releaseName};
      files = lib.filesystem.listFilesRecursive (lib.path.append ./. releaseName);
      mesonFiles = lib.filter (hasBasenamePrefix "meson") files;
    in
    # You have to have at least `meson.build.in` when using xcodeHash to trigger the Meson
    # 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;

        src = super.src or fetchFromGitHub {
      src = args.src or fetchFromGitHub {
        owner = "apple-oss-distributions";
        repo = releaseName;
        rev = info.rev or "${releaseName}-${info.version}";
@@ -62,11 +48,11 @@ lib.makeOverridable (
        teams = [ lib.teams.darwin ];
        platforms = lib.platforms.darwin;
      }
        // super.meta or { };
      // args.meta or { };
    }
      // lib.optionalAttrs (super ? xcodeHash) {
    // lib.optionalAttrs (args ? xcodeHash) {
      postUnpack =
          super.postUnpack or ""
        args.postUnpack or ""
        + lib.concatMapStrings (
          file:
          if baseNameOf file == "meson.build.in" then
@@ -75,16 +61,14 @@ lib.makeOverridable (
            "cp ${lib.escapeShellArg "${file}"} \"$sourceRoot/\"${lib.escapeShellArg (baseNameOf file)}\n"
        ) mesonFiles;

        xcodeProject = super.xcodeProject or "${releaseName}.xcodeproj";
      xcodeProject = args.xcodeProject or "${releaseName}.xcodeproj";

        nativeBuildInputs = super.nativeBuildInputs or [ ] ++ [
      nativeBuildInputs = args.nativeBuildInputs or [ ] ++ [
        meson
        ninja
        xcodeProjectCheckHook
      ];

      mesonBuildType = "release";
    };
}
    ) attrs'
  )
)