nixpkgs/pkgs/development/compilers/swift/sourcekit-lsp/default.nix

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

75 lines
2.1 KiB
Nix
Raw Normal View History

2022-07-30 15:33:18 +00:00
{ lib
, stdenv
, callPackage
, fetchFromGitHub
, swift
, swiftpm
, Foundation
, XCTest
, sqlite
, ncurses
, CryptoKit
, LocalAuthentication
}:
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 = "sourcekit-lsp";
# Releases are made as part of the Swift toolchain, so versions should match.
version = "5.7";
src = fetchFromGitHub {
owner = "apple";
repo = "sourcekit-lsp";
rev = "swift-${version}-RELEASE";
hash = "sha256-uA3a+kAqI+XFzkDFEJ8XuRTgfYqacEuTsOU289Im+0Y=";
};
nativeBuildInputs = [ swift swiftpm ];
buildInputs = [
Foundation
XCTest
sqlite
ncursesInput
]
++ lib.optionals stdenv.isDarwin [ CryptoKit LocalAuthentication ];
configurePhase = generated.configure + ''
swiftpmMakeMutable indexstore-db
patch -p1 -d .build/checkouts/indexstore-db -i ${./patches/indexstore-db-macos-target.patch}
# This toggles a section specific to Xcode XCTest, which doesn't work on
# Darwin, where we also use swift-corelibs-xctest.
substituteInPlace Sources/LSPTestSupport/PerfTestCase.swift \
--replace '#if os(macOS)' '#if false'
# Required to link with swift-corelibs-xctest on Darwin.
export SWIFTTSC_MACOS_DEPLOYMENT_TARGET=10.12
'';
# TODO: BuildServerBuildSystemTests fails
#doCheck = true;
installPhase = ''
binPath="$(swiftpmBinPath)"
mkdir -p $out/bin
cp $binPath/sourcekit-lsp $out/bin/
'';
meta = {
description = "Language Server Protocol implementation for Swift and C-based languages";
homepage = "https://github.com/apple/sourcekit-lsp";
platforms = with lib.platforms; linux ++ darwin;
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ dtzWill trepetti dduan trundle stephank ];
};
}