mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 07:23:20 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
56 lines
1.7 KiB
Nix
56 lines
1.7 KiB
Nix
{ lib
|
|
, stdenv
|
|
, callPackage
|
|
, cmake
|
|
, ninja
|
|
, swift
|
|
, Foundation
|
|
, DarwinTools
|
|
}:
|
|
|
|
let
|
|
sources = callPackage ../sources.nix { };
|
|
in stdenv.mkDerivation {
|
|
pname = "swift-corelibs-xctest";
|
|
|
|
inherit (sources) version;
|
|
src = sources.swift-corelibs-xctest;
|
|
|
|
outputs = [ "out" ];
|
|
|
|
nativeBuildInputs = [ cmake ninja swift ]
|
|
++ lib.optional stdenv.hostPlatform.isDarwin DarwinTools; # sw_vers
|
|
buildInputs = [ Foundation ];
|
|
|
|
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
# On Darwin only, Swift uses arm64 as cpu arch.
|
|
substituteInPlace cmake/modules/SwiftSupport.cmake \
|
|
--replace '"aarch64" PARENT_SCOPE' '"arm64" PARENT_SCOPE'
|
|
'';
|
|
|
|
preConfigure = ''
|
|
# On aarch64-darwin, our minimum target is 11.0, but we can target lower,
|
|
# and some dependants require a lower target. Harmless on non-Darwin.
|
|
export MACOSX_DEPLOYMENT_TARGET=10.12
|
|
'';
|
|
|
|
cmakeFlags = lib.optional stdenv.hostPlatform.isDarwin "-DUSE_FOUNDATION_FRAMEWORK=ON";
|
|
|
|
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
# Darwin normally uses the Xcode version of XCTest. Installing
|
|
# swift-corelibs-xctest is probably not officially supported, but we have
|
|
# no alternative. Fix up the installation here.
|
|
mv $out/lib/swift/darwin/${swift.swiftArch}/* $out/lib/swift/darwin
|
|
rmdir $out/lib/swift/darwin/${swift.swiftArch}
|
|
mv $out/lib/swift/darwin $out/lib/swift/${swift.swiftOs}
|
|
'';
|
|
|
|
meta = {
|
|
description = "Framework for writing unit tests in Swift";
|
|
homepage = "https://github.com/apple/swift-corelibs-xctest";
|
|
platforms = lib.platforms.all;
|
|
license = lib.licenses.asl20;
|
|
maintainers = lib.teams.swift.members;
|
|
};
|
|
}
|