nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 89 lines 2.5 kB view raw
1{ 2 lib, 3 stdenv, 4 callPackage, 5 fetchpatch, 6 pkg-config, 7 swift, 8 swiftpm, 9 swiftpm2nix, 10 Dispatch, 11 Foundation, 12 XCTest, 13 sqlite, 14 ncurses, 15}: 16let 17 sources = callPackage ../sources.nix { }; 18 generated = swiftpm2nix.helpers ./generated; 19 20 # On Darwin, we only want ncurses in the linker search path, because headers 21 # are part of libsystem. Adding its headers to the search path causes strange 22 # mixing and errors. 23 # TODO: Find a better way to prevent this conflict. 24 ncursesInput = if stdenv.hostPlatform.isDarwin then ncurses.out else ncurses; 25in 26stdenv.mkDerivation { 27 pname = "sourcekit-lsp"; 28 29 inherit (sources) version; 30 src = sources.sourcekit-lsp; 31 32 nativeBuildInputs = [ 33 pkg-config 34 swift 35 swiftpm 36 ]; 37 buildInputs = [ 38 Foundation 39 XCTest 40 sqlite 41 ncursesInput 42 ]; 43 44 env.LD_LIBRARY_PATH = lib.optionalString stdenv.hostPlatform.isLinux ( 45 lib.makeLibraryPath [ Dispatch ] 46 ); 47 48 configurePhase = generated.configure + '' 49 swiftpmMakeMutable indexstore-db 50 patch -p1 -d .build/checkouts/indexstore-db -i ${./patches/indexstore-db-macos-target.patch} 51 patch -p1 -d .build/checkouts/indexstore-db -i ${ 52 # Fix the build with modern Clang. 53 fetchpatch { 54 url = "https://github.com/swiftlang/indexstore-db/commit/6120b53b1e8774ef4e2ad83438d4d94961331e72.patch"; 55 hash = "sha256-tMAfTIa3RKiA/jDtP02mHcpPaF2s9a+3q/PLJxqn30M="; 56 } 57 } 58 59 # This toggles a section specific to Xcode XCTest, which doesn't work on 60 # Darwin, where we also use swift-corelibs-xctest. 61 substituteInPlace Sources/LSPTestSupport/PerfTestCase.swift \ 62 --replace-fail '#if os(macOS)' '#if false' 63 64 # Required to link with swift-corelibs-xctest on Darwin. 65 export SWIFTTSC_MACOS_DEPLOYMENT_TARGET=10.12 66 ''; 67 68 # TODO: BuildServerBuildSystemTests fails 69 #doCheck = true; 70 71 installPhase = '' 72 binPath="$(swiftpmBinPath)" 73 mkdir -p $out/bin 74 cp $binPath/sourcekit-lsp $out/bin/ 75 ''; 76 77 # Canary to verify output of our Swift toolchain does not depend on the Swift 78 # compiler itself. (Only its 'lib' output.) 79 disallowedRequisites = [ swift.swift ]; 80 81 meta = { 82 description = "Language Server Protocol implementation for Swift and C-based languages"; 83 mainProgram = "sourcekit-lsp"; 84 homepage = "https://github.com/apple/sourcekit-lsp"; 85 platforms = with lib.platforms; linux ++ darwin; 86 license = lib.licenses.asl20; 87 teams = [ lib.teams.swift ]; 88 }; 89}