at master 2.1 kB view raw
1{ 2 lib, 3 stdenv, 4 callPackage, 5 swift, 6 swiftpm, 7 swiftpm2nix, 8 Foundation, 9 XCTest, 10}: 11let 12 sources = callPackage ../sources.nix { }; 13 generated = swiftpm2nix.helpers ./generated; 14in 15stdenv.mkDerivation { 16 pname = "swift-docc"; 17 18 inherit (sources) version; 19 src = sources.swift-docc; 20 # TODO: We could build this from `apple/swift-docc-render` source, but that 21 # repository is not tagged. 22 renderArtifact = sources.swift-docc-render-artifact; 23 24 nativeBuildInputs = [ 25 swift 26 swiftpm 27 ]; 28 buildInputs = [ 29 Foundation 30 XCTest 31 ]; 32 33 configurePhase = 34 generated.configure 35 # Fix the build with modern Clang. 36 # 37 # Based on the upstream fix for Musl: 38 # <https://github.com/apple/swift-nio/commit/fc6e3c0eefb28adf641531180b81aaf41b02ed20> 39 + '' 40 swiftpmMakeMutable swift-nio 41 patch -p1 -d .build/checkouts/swift-nio -i ${./fix-swift-nio.patch} 42 ''; 43 44 # We only install the docc binary, so don't need the other products. 45 # This works around a failure building generate-symbol-graph: 46 # Sources/generate-symbol-graph/main.swift:13:18: error: module 'SwiftDocC' was not compiled for testing 47 # TODO: Figure out the cause. It doesn't seem to happen outside Nixpkgs. 48 swiftpmFlags = [ "--product docc" ]; 49 50 # TODO: Tests depend on indexstore-db being provided by an existing Swift 51 # toolchain. (ie. looks for `../lib/libIndexStore.so` relative to swiftc. 52 #doCheck = true; 53 54 installPhase = '' 55 binPath="$(swiftpmBinPath)" 56 mkdir -p $out/bin $out/share/docc 57 cp $binPath/docc $out/bin/ 58 ln -s $renderArtifact/dist $out/share/docc/render 59 ''; 60 61 # Canary to verify output of our Swift toolchain does not depend on the Swift 62 # compiler itself. (Only its 'lib' output.) 63 disallowedRequisites = [ swift.swift ]; 64 65 meta = { 66 description = "Documentation compiler for Swift"; 67 mainProgram = "docc"; 68 homepage = "https://github.com/apple/swift-docc"; 69 platforms = with lib.platforms; linux ++ darwin; 70 license = lib.licenses.asl20; 71 teams = [ lib.teams.swift ]; 72 }; 73}