1{
2 lib,
3 swiftPackages,
4 swift,
5 swiftpm,
6 swiftpm2nix,
7 fetchFromGitHub,
8 versionCheckHook,
9 nix-update-script,
10 ...
11}:
12
13let
14 # Pass the generated files to the helper.
15 generated = swiftpm2nix.helpers ./nix;
16in
17
18swiftPackages.stdenv.mkDerivation (finalAttrs: {
19 pname = "xcodegen";
20 version = "2.42.0";
21
22 src = fetchFromGitHub {
23 owner = "yonaskolb";
24 repo = "XcodeGen";
25 tag = finalAttrs.version;
26 hash = "sha256-wcjmADG+XnS2kR8BHe6ijApomucS9Tx7ZRjWZmTCUiI=";
27 };
28
29 # Including SwiftPM as a nativeBuildInput provides a buildPhase for you.
30 # This by default performs a release build using SwiftPM, essentially:
31 # swift build -c release
32 nativeBuildInputs = [
33 swift
34 swiftpm
35 ];
36
37 buildInputs = [
38 swiftPackages.XCTest
39 ];
40
41 # The helper provides a configure snippet that will prepare all dependencies
42 # in the correct place, where SwiftPM expects them.
43 configurePhase = generated.configure + ''
44 # Replace the dependency symlink with a writable copy
45 swiftpmMakeMutable Spectre
46 # Now apply a patch
47 patch -p1 -d .build/checkouts/Spectre -i ${./0001-spectre-xct-record.patch}
48 '';
49
50 installPhase = ''
51 mkdir -p $out/bin $out/share/xcodegen
52 cp "$(swiftpmBinPath)/${finalAttrs.pname}" $out/bin/
53 cp -r SettingPresets $out/share/xcodegen/SettingPresets
54 '';
55
56 nativeInstallCheckInputs = [
57 versionCheckHook
58 ];
59 versionCheckProgramArg = "--version";
60 doInstallCheck = true;
61
62 passthru = {
63 updateScript = nix-update-script { };
64 };
65
66 meta = {
67 description = "Swift command line tool for generating your Xcode project";
68 homepage = "https://github.com/yonaskolb/XcodeGen";
69 changelog = "https://github.com/XcodeGen/blob/${finalAttrs.version}/CHANGELOG.md";
70 license = lib.licenses.mit;
71 platforms = lib.platforms.darwin;
72 maintainers = [ lib.maintainers.samasaur ];
73 mainProgram = "xcodegen";
74 };
75})