lol
1{ lib
2, stdenv
3, fetchpatch
4, callPackage
5, swift
6, swiftpm
7, swiftpm2nix
8, Foundation
9}:
10let
11 sources = callPackage ../sources.nix { };
12 generated = swiftpm2nix.helpers ./generated;
13in
14stdenv.mkDerivation {
15 pname = "swift-format";
16
17 inherit (sources) version;
18 src = sources.swift-format;
19
20 nativeBuildInputs = [ swift swiftpm ];
21 buildInputs = [ Foundation ];
22
23 configurePhase = generated.configure + ''
24 swiftpmMakeMutable swift-tools-support-core
25 patch -p1 -d .build/checkouts/swift-tools-support-core -i ${fetchpatch {
26 url = "https://github.com/apple/swift-tools-support-core/commit/990afca47e75cce136d2f59e464577e68a164035.patch";
27 hash = "sha256-PLzWsp+syiUBHhEFS8+WyUcSae5p0Lhk7SSRdNvfouE=";
28 includes = [ "Sources/TSCBasic/FileSystem.swift" ];
29 }}
30 '';
31
32 # We only install the swift-format binary, so don't need the other products.
33 swiftpmFlags = [ "--product swift-format" ];
34
35 installPhase = ''
36 binPath="$(swiftpmBinPath)"
37 mkdir -p $out/bin
38 cp $binPath/swift-format $out/bin/
39 '';
40
41 meta = {
42 description = "Formatting technology for Swift source code";
43 homepage = "https://github.com/apple/swift-format";
44 platforms = with lib.platforms; linux ++ darwin;
45 license = lib.licenses.asl20;
46 maintainers = with lib.maintainers; [ dtzWill trepetti dduan trundle stephank ];
47 mainProgram = "swift-format";
48 };
49}