1{ stdenv, lib, fetchFromGitHub, runCommand }:
2
3# This derivation is impure: it relies on an Xcode toolchain being installed
4# and available in the expected place. The values of sandboxProfile and
5# hydraPlatforms are copied pretty directly from the MacVim derivation, which
6# is also impure.
7
8stdenv.mkDerivation rec {
9 pname = "swiftformat";
10 version = "0.47.10";
11
12 src = fetchFromGitHub {
13 owner = "nicklockwood";
14 repo = "SwiftFormat";
15 rev = version;
16 sha256 = "1gqxpymbhpmap0i2blg9akarlql4mkzv45l4i212gsxcs991b939";
17 };
18
19 preConfigure = "LD=$CC";
20
21 buildPhase = ''
22 /usr/bin/xcodebuild -project SwiftFormat.xcodeproj \
23 -scheme "SwiftFormat (Command Line Tool)" \
24 CODE_SIGN_IDENTITY= SYMROOT=build OBJROOT=build
25 '';
26
27 installPhase = ''
28 install -D -m 0555 build/Release/swiftformat $out/bin/swiftformat
29 '';
30
31 sandboxProfile = ''
32 (allow file-read* file-write* process-exec mach-lookup)
33 ; block homebrew dependencies
34 (deny file-read* file-write* process-exec mach-lookup (subpath "/usr/local") (with no-log))
35 '';
36
37 meta = with lib; {
38 description = "A code formatting and linting tool for Swift";
39 homepage = "https://github.com/nicklockwood/SwiftFormat";
40 license = licenses.mit;
41 maintainers = [ maintainers.bdesham ];
42 platforms = platforms.darwin;
43 hydraPlatforms = [];
44 };
45}