about summary refs log tree commit diff
path: root/pkgs/development/compilers/swift/swift-format
diff options
context:
space:
mode:
authorWeijia Wang <9713184+wegank@users.noreply.github.com>2024-01-13 22:47:23 +0100
committerGitHub <noreply@github.com>2024-01-13 22:47:23 +0100
commita291d04a1578b7dcd020ba475f0fa3552914dc46 (patch)
tree81e1430217ad71d72ad699887c331a938d00a185 /pkgs/development/compilers/swift/swift-format
parentb3018aec79f5808c5e9e83014f032d0a65c5e57b (diff)
parent92e04e12ca7402b0e98172847edd78246cf23a80 (diff)
Merge pull request #269015 from paveloom/swiftpm
swift: force-unwrap file handles in `swift-tools-support-core`
Diffstat (limited to 'pkgs/development/compilers/swift/swift-format')
-rw-r--r--pkgs/development/compilers/swift/swift-format/default.nix5
-rw-r--r--pkgs/development/compilers/swift/swift-format/patches/force-unwrap-file-handles.patch33
2 files changed, 37 insertions, 1 deletions
diff --git a/pkgs/development/compilers/swift/swift-format/default.nix b/pkgs/development/compilers/swift/swift-format/default.nix
index d68801aac6e2d..2f7e630e68045 100644
--- a/pkgs/development/compilers/swift/swift-format/default.nix
+++ b/pkgs/development/compilers/swift/swift-format/default.nix
@@ -19,7 +19,10 @@ stdenv.mkDerivation {
   nativeBuildInputs = [ swift swiftpm ];
   buildInputs = [ Foundation ];
 
-  configurePhase = generated.configure;
+  configurePhase = generated.configure + ''
+    swiftpmMakeMutable swift-tools-support-core
+    patch -p1 -d .build/checkouts/swift-tools-support-core -i ${./patches/force-unwrap-file-handles.patch}
+  '';
 
   # We only install the swift-format binary, so don't need the other products.
   swiftpmFlags = [ "--product swift-format" ];
diff --git a/pkgs/development/compilers/swift/swift-format/patches/force-unwrap-file-handles.patch b/pkgs/development/compilers/swift/swift-format/patches/force-unwrap-file-handles.patch
new file mode 100644
index 0000000000000..a2f2d38c37c81
--- /dev/null
+++ b/pkgs/development/compilers/swift/swift-format/patches/force-unwrap-file-handles.patch
@@ -0,0 +1,33 @@
+From 8d9ab4b6ed24a97e8af0cc338a52aacdcf438b8c Mon Sep 17 00:00:00 2001
+From: Pavel Sobolev <paveloom@riseup.net>
+Date: Tue, 21 Nov 2023 20:53:33 +0300
+Subject: [PATCH] Force-unwrap file handles.
+
+---
+ Sources/TSCBasic/FileSystem.swift | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Sources/TSCBasic/FileSystem.swift b/Sources/TSCBasic/FileSystem.swift
+index 3a63bdf..a1f3d9d 100644
+--- a/Sources/TSCBasic/FileSystem.swift
++++ b/Sources/TSCBasic/FileSystem.swift
+@@ -425,7 +425,7 @@ private class LocalFileSystem: FileSystem {
+         if fp == nil {
+             throw FileSystemError(errno: errno, path)
+         }
+-        defer { fclose(fp) }
++        defer { fclose(fp!) }
+
+         // Read the data one block at a time.
+         let data = BufferedOutputByteStream()
+@@ -455,7 +455,7 @@ private class LocalFileSystem: FileSystem {
+         if fp == nil {
+             throw FileSystemError(errno: errno, path)
+         }
+-        defer { fclose(fp) }
++        defer { fclose(fp!) }
+
+         // Write the data in one chunk.
+         var contents = bytes.contents
+--
+2.42.0