Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib 2, stdenv 3, callPackage 4, swift 5, swiftpm 6, swiftpm2nix 7, Foundation 8, XCTest 9, CryptoKit 10, LocalAuthentication 11}: 12let 13 sources = callPackage ../sources.nix { }; 14 generated = swiftpm2nix.helpers ./generated; 15in 16stdenv.mkDerivation { 17 pname = "swift-docc"; 18 19 inherit (sources) version; 20 src = sources.swift-docc; 21 # TODO: We could build this from `apple/swift-docc-render` source, but that 22 # repository is not tagged. 23 renderArtifact = sources.swift-docc-render-artifact; 24 25 nativeBuildInputs = [ swift swiftpm ]; 26 buildInputs = [ Foundation XCTest ] 27 ++ lib.optionals stdenv.isDarwin [ CryptoKit LocalAuthentication ]; 28 29 configurePhase = generated.configure; 30 31 # We only install the docc binary, so don't need the other products. 32 # This works around a failure building generate-symbol-graph: 33 # Sources/generate-symbol-graph/main.swift:13:18: error: module 'SwiftDocC' was not compiled for testing 34 # TODO: Figure out the cause. It doesn't seem to happen outside Nixpkgs. 35 swiftpmFlags = [ "--product docc" ]; 36 37 # TODO: Tests depend on indexstore-db being provided by an existing Swift 38 # toolchain. (ie. looks for `../lib/libIndexStore.so` relative to swiftc. 39 #doCheck = true; 40 41 installPhase = '' 42 binPath="$(swiftpmBinPath)" 43 mkdir -p $out/bin $out/share/docc 44 cp $binPath/docc $out/bin/ 45 ln -s $renderArtifact/dist $out/share/docc/render 46 ''; 47 48 # Canary to verify output of our Swift toolchain does not depend on the Swift 49 # compiler itself. (Only its 'lib' output.) 50 disallowedRequisites = [ swift.swift ]; 51 52 meta = { 53 description = "Documentation compiler for Swift"; 54 homepage = "https://github.com/apple/swift-docc"; 55 platforms = with lib.platforms; linux ++ darwin; 56 license = lib.licenses.asl20; 57 maintainers = with lib.maintainers; [ dtzWill trepetti dduan trundle stephank ]; 58 }; 59}