1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-27 03:26:50 +03:00
nixpkgs/pkgs/development/compilers/swift/swift-driver/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

84 lines
2.3 KiB
Nix
Raw Normal View History

2022-08-26 08:09:17 +02:00
{ lib
, stdenv
, callPackage
, fetchFromGitHub
, fetchpatch
, swift
, swiftpm
, Foundation
, XCTest
, sqlite
, ncurses
, substituteAll
}:
let
# Generated by swiftpm2nix.
generated = callPackage ./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 rec {
pname = "swift-driver";
# Releases are made as part of the Swift toolchain, so versions should match.
version = "5.7";
src = fetchFromGitHub {
owner = "apple";
repo = "swift-driver";
rev = "swift-${version}-RELEASE";
hash = "sha256-sk7XWXYR1MGPEeVxA6eA/vxhN6Gq16iD1RHpVstL3zE=";
};
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;
# 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 ];
};
}