about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2023-05-07 09:59:10 +0300
committerGitHub <noreply@github.com>2023-05-07 09:59:10 +0300
commiteb751d65225ec53de9cf3d88acbf08d275882389 (patch)
tree1e69f5733975d12dcfb49331ca0d60a679459667 /pkgs
parent933c8e6fd21bc3193c69b43809fdc945d172eef2 (diff)
parent1f5b3796839f6a7ad897a57b1eeb179eb3f1130c (diff)
Merge pull request #230372 from stephank/feat/swift-format
swift-format: init at 5.8
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/compilers/swift/default.nix2
-rw-r--r--pkgs/development/compilers/swift/sources.nix1
-rw-r--r--pkgs/development/compilers/swift/swift-format/default.nix40
-rw-r--r--pkgs/development/compilers/swift/swift-format/generated/default.nix10
-rw-r--r--pkgs/development/compilers/swift/swift-format/generated/workspace-state.json76
-rw-r--r--pkgs/top-level/all-packages.nix2
6 files changed, 130 insertions, 1 deletions
diff --git a/pkgs/development/compilers/swift/default.nix b/pkgs/development/compilers/swift/default.nix
index 3012c9a2f177c..2df883095cf15 100644
--- a/pkgs/development/compilers/swift/default.nix
+++ b/pkgs/development/compilers/swift/default.nix
@@ -97,6 +97,8 @@ let
       inherit (apple_sdk.frameworks) CryptoKit LocalAuthentication;
     };
 
+    swift-format = callPackage ./swift-format { };
+
   };
 
 in self
diff --git a/pkgs/development/compilers/swift/sources.nix b/pkgs/development/compilers/swift/sources.nix
index 739fe8254f307..11240f767d08e 100644
--- a/pkgs/development/compilers/swift/sources.nix
+++ b/pkgs/development/compilers/swift/sources.nix
@@ -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=";
   };
diff --git a/pkgs/development/compilers/swift/swift-format/default.nix b/pkgs/development/compilers/swift/swift-format/default.nix
new file mode 100644
index 0000000000000..95a8f5614ab23
--- /dev/null
+++ b/pkgs/development/compilers/swift/swift-format/default.nix
@@ -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 ];
+  };
+}
diff --git a/pkgs/development/compilers/swift/swift-format/generated/default.nix b/pkgs/development/compilers/swift/swift-format/generated/default.nix
new file mode 100644
index 0000000000000..ec4969bc60b50
--- /dev/null
+++ b/pkgs/development/compilers/swift/swift-format/generated/default.nix
@@ -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";
+  };
+}
diff --git a/pkgs/development/compilers/swift/swift-format/generated/workspace-state.json b/pkgs/development/compilers/swift/swift-format/generated/workspace-state.json
new file mode 100644
index 0000000000000..b726eefc56ee5
--- /dev/null
+++ b/pkgs/development/compilers/swift/swift-format/generated/workspace-state.json
@@ -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
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 2c505af1149bd..d17ccef583dde 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -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 { };