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