mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-30 08:44:31 +00:00
2dcdf60272
Failing Hydra build: https://hydra.nixos.org/build/249763077/nixlog/12 The problem is that glibc commit 64b1a44183a3094672ed304532bedb9acc707554 marked the `FILE*` argument of a few functions including `fread` & `ferror` as non-null. The applied patch ("Android: add better nullability checks for nullability annotations added in NDK 26") is targeted for the Android platform, but fixes said issue as well: the handle returned from `fopen` is of type `Optional<T>` and the `guard` expression unwraps that now (and throws an exception if `nil` is returned). The previous `nil`-check didn't modify the type of `fp`, but only raised the exception and moved on with `Optional<T>`. It's a little sad that the patch needs to be applied at so many places, but I guess that's what you get with language-level package managers 🤷 Also, seems good-enough to me given that it's actually temporary, the patch is already upstream and will probably be obsolete at one of the next Swift updates.
85 lines
2.5 KiB
Nix
85 lines
2.5 KiB
Nix
{ lib
|
|
, stdenv
|
|
, callPackage
|
|
, fetchpatch
|
|
, swift
|
|
, swiftpm
|
|
, swiftpm2nix
|
|
, Foundation
|
|
, XCTest
|
|
, sqlite
|
|
, ncurses
|
|
, substituteAll
|
|
}:
|
|
let
|
|
sources = callPackage ../sources.nix { };
|
|
generated = swiftpm2nix.helpers ./generated;
|
|
|
|
# On Darwin, we only want ncurses in the linker search path, because headers
|
|
# are part of libsystem. Adding its headers to the search path causes strange
|
|
# mixing and errors.
|
|
# TODO: Find a better way to prevent this conflict.
|
|
ncursesInput = if stdenv.isDarwin then ncurses.out else ncurses;
|
|
in
|
|
stdenv.mkDerivation {
|
|
pname = "swift-driver";
|
|
|
|
inherit (sources) version;
|
|
src = sources.swift-driver;
|
|
|
|
nativeBuildInputs = [ swift swiftpm ];
|
|
buildInputs = [
|
|
Foundation
|
|
XCTest
|
|
sqlite
|
|
ncursesInput
|
|
];
|
|
|
|
patches = [
|
|
./patches/nix-resource-root.patch
|
|
./patches/disable-catalyst.patch
|
|
./patches/linux-fix-linking.patch
|
|
# TODO: Replace with branch patch once merged:
|
|
# https://github.com/apple/swift-driver/pull/1197
|
|
(fetchpatch {
|
|
url = "https://github.com/apple/swift-driver/commit/d3ef9cdf4871a58eddec7ff0e28fe611130da3f9.patch";
|
|
hash = "sha256-eVBaKN6uzj48ZnHtwGV0k5ChKjak1tDCyE+wTdyGq2c=";
|
|
})
|
|
# Prevent a warning about SDK directories we don't have.
|
|
(substituteAll {
|
|
src = ./patches/prevent-sdk-dirs-warnings.patch;
|
|
inherit (builtins) storeDir;
|
|
})
|
|
];
|
|
|
|
configurePhase = generated.configure + ''
|
|
swiftpmMakeMutable swift-tools-support-core
|
|
patch -p1 -d .build/checkouts/swift-tools-support-core -i ${fetchpatch {
|
|
url = "https://github.com/apple/swift-tools-support-core/commit/990afca47e75cce136d2f59e464577e68a164035.patch";
|
|
hash = "sha256-PLzWsp+syiUBHhEFS8+WyUcSae5p0Lhk7SSRdNvfouE=";
|
|
includes = [ "Sources/TSCBasic/FileSystem.swift" ];
|
|
}}
|
|
'';
|
|
|
|
# TODO: Tests depend on indexstore-db being provided by an existing Swift
|
|
# toolchain. (ie. looks for `../lib/libIndexStore.so` relative to swiftc.
|
|
#doCheck = true;
|
|
|
|
# TODO: Darwin-specific installation includes more, but not sure why.
|
|
installPhase = ''
|
|
binPath="$(swiftpmBinPath)"
|
|
mkdir -p $out/bin
|
|
for executable in swift-driver swift-help swift-build-sdk-interfaces; do
|
|
cp $binPath/$executable $out/bin/
|
|
done
|
|
'';
|
|
|
|
meta = {
|
|
description = "Swift compiler driver";
|
|
homepage = "https://github.com/apple/swift-driver";
|
|
platforms = with lib.platforms; linux ++ darwin;
|
|
license = lib.licenses.asl20;
|
|
maintainers = with lib.maintainers; [ dtzWill trepetti dduan trundle stephank ];
|
|
};
|
|
}
|