nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchpatch,
5 callPackage,
6 swift,
7 swiftpm,
8 swiftpm2nix,
9 Dispatch,
10 Foundation,
11}:
12let
13 sources = callPackage ../sources.nix { };
14 generated = swiftpm2nix.helpers ./generated;
15in
16stdenv.mkDerivation {
17 pname = "swift-format";
18
19 inherit (sources) version;
20 src = sources.swift-format;
21
22 nativeBuildInputs = [
23 swift
24 swiftpm
25 ];
26 buildInputs = [ Foundation ];
27
28 env.LD_LIBRARY_PATH = lib.optionalString stdenv.hostPlatform.isLinux (
29 lib.makeLibraryPath [ Dispatch ]
30 );
31
32 configurePhase = generated.configure;
33
34 # We only install the swift-format binary, so don't need the other products.
35 swiftpmFlags = [ "--product swift-format" ];
36
37 installPhase = ''
38 binPath="$(swiftpmBinPath)"
39 mkdir -p $out/bin
40 cp $binPath/swift-format $out/bin/
41 '';
42
43 meta = {
44 description = "Formatting technology for Swift source code";
45 homepage = "https://github.com/apple/swift-format";
46 platforms = with lib.platforms; linux ++ darwin;
47 license = lib.licenses.asl20;
48 teams = [ lib.teams.swift ];
49 mainProgram = "swift-format";
50 };
51}