Skip to content

Commit

Permalink
Merge pull request #230372 from stephank/feat/swift-format
Browse files Browse the repository at this point in the history
swift-format: init at 5.8
  • Loading branch information
wegank committed May 7, 2023
2 parents 933c8e6 + 1f5b379 commit eb751d6
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkgs/development/compilers/swift/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ let
inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
};

swift-format = callPackage ./swift-format { };

};

in self
1 change: 1 addition & 0 deletions pkgs/development/compilers/swift/sources.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let
swift-docc-render-artifact = "sha256-vdSyICXOjlNSjZXzPRxa/5305pg6PG4xww9GYEV9m10=";
swift-driver = "sha256-7xsG3Bpf+wqisCMaPEuEg8CjGYO/0r8BX3pMUmRrezE=";
swift-experimental-string-processing = "sha256-ioXG6pQKjlAc2oF38Z7TGighyZN8w2ZAAtFUq83Ow6Q=";
swift-format = "sha256-uKhIcbJb0DDHKACfVrhQ4fSyXVUkAj090eUZsOrtEqw=";
swift-package-manager = "sha256-xd6ZpeXfMoHyVrJxz6XcDLPKBvc2nl1lgWXuLrJdq+E=";
swift-syntax = "sha256-gkpx/1sWWi9y917OJ1GSNFYXrJb6e2qI4JlV+38laRQ=";
};
Expand Down
40 changes: 40 additions & 0 deletions pkgs/development/compilers/swift/swift-format/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{ lib
, stdenv
, callPackage
, swift
, swiftpm
, swiftpm2nix
, Foundation
}:
let
sources = callPackage ../sources.nix { };
generated = swiftpm2nix.helpers ./generated;
in
stdenv.mkDerivation {
pname = "swift-format";

inherit (sources) version;
src = sources.swift-format;

nativeBuildInputs = [ swift swiftpm ];
buildInputs = [ Foundation ];

configurePhase = generated.configure;

# We only install the swift-format binary, so don't need the other products.
swiftpmFlags = "--product swift-format";

installPhase = ''
binPath="$(swiftpmBinPath)"
mkdir -p $out/bin
cp $binPath/swift-format $out/bin/
'';

meta = {
description = "Formatting technology for Swift source code";
homepage = "https://github.com/apple/swift-format";
platforms = with lib.platforms; linux ++ darwin;
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ dtzWill trepetti dduan trundle stephank ];
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file was generated by swiftpm2nix.
{
workspaceStateFile = ./workspace-state.json;
hashes = {
"swift-argument-parser" = "01p814snzlfpby2qj67a3dcnsa6038fbk8411npi28440w1hzpzx";
"swift-syntax" = "05394mzznmcrw246lyzsjsn1fmilj98jgkjyyxr2ynhnbgzp2jl2";
"swift-system" = "0402hkx2q2dv27gccnn8ma79ngvwiwzkhcv4zlcdldmy6cgi0px7";
"swift-tools-support-core" = "16kp0y1akr99v319j46x0zwc8kzh5klnqcvjhsb57ah5xr0l29bk";
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"object": {
"artifacts": [],
"dependencies": [
{
"basedOn": null,
"packageRef": {
"identity": "swift-argument-parser",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-argument-parser.git",
"name": "swift-argument-parser"
},
"state": {
"checkoutState": {
"branch": "main",
"revision": "c5050aa63ed5bb23209e7120b7ff6618ee06e0ee"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-argument-parser"
},
{
"basedOn": null,
"packageRef": {
"identity": "swift-syntax",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-syntax.git",
"name": "SwiftSyntax"
},
"state": {
"checkoutState": {
"branch": "main",
"revision": "cd793adf5680e138bf2bcbaacc292490175d0dcd"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-syntax"
},
{
"basedOn": null,
"packageRef": {
"identity": "swift-system",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-system.git",
"name": "swift-system"
},
"state": {
"checkoutState": {
"revision": "836bc4557b74fe6d2660218d56e3ce96aff76574",
"version": "1.1.1"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-system"
},
{
"basedOn": null,
"packageRef": {
"identity": "swift-tools-support-core",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-tools-support-core.git",
"name": "swift-tools-support-core"
},
"state": {
"checkoutState": {
"branch": "main",
"revision": "1296d2f11b0226c4b83540010936c7238d21c12b"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-tools-support-core"
}
]
},
"version": 6
}
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16453,7 +16453,7 @@ with pkgs;
svdtools = callPackage ../development/embedded/svdtools { };

swiftPackages = recurseIntoAttrs (callPackage ../development/compilers/swift { });
inherit (swiftPackages) swift swiftpm sourcekit-lsp;
inherit (swiftPackages) swift swiftpm sourcekit-lsp swift-format;

swiftpm2nix = callPackage ../development/tools/swiftpm2nix { };

Expand Down

0 comments on commit eb751d6

Please sign in to comment.