diff --git a/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix b/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix index c4dfea8bafee..70af831142a9 100644 --- a/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix +++ b/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix @@ -88,6 +88,11 @@ lib.mapAttrs mkInstallScript { SwiftCrypto = '' add_library(Crypto SHARED IMPORTED) set_property(TARGET Crypto PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libCrypto@sharedLibExt@") + + add_library(_CryptoExtras SHARED IMPORTED) + # this can't possibly be right... I really think it should be `libCryptoExtras` + # swift-certificates did build with this though..... + set_property(TARGET _CryptoExtras PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libCrypto@sharedLibExt@") ''; SwiftASN1 = '' diff --git a/pkgs/development/compilers/swift/swiftpm/default.nix b/pkgs/development/compilers/swift/swiftpm/default.nix index 7eca5fd158de..1de77a55bdff 100644 --- a/pkgs/development/compilers/swift/swiftpm/default.nix +++ b/pkgs/development/compilers/swift/swiftpm/default.nix @@ -23,7 +23,11 @@ let - inherit (swift) swiftOs swiftModuleSubdir swiftStaticModuleSubdir; + inherit (swift) + swiftOs + swiftModuleSubdir + swiftStaticModuleSubdir + ; sharedLibraryExt = stdenv.hostPlatform.extensions.sharedLibrary; sources = callPackage ../sources.nix { }; @@ -322,6 +326,14 @@ let fetchSubmodules = true; }; + buildInputs = [ + swift-asn1 + ]; + + patches = [ + ./patches/install-crypto-extras.patch + ]; + postPatch = '' # Fix use of hardcoded tool paths on Darwin. substituteInPlace CMakeLists.txt \ @@ -336,6 +348,12 @@ let # Headers are not installed. cp -r ../Sources/CCryptoBoringSSL/include $out/include + + # Swift modules are put in the wrong place by default (and not all are linked) + mkdir -p $out/${swiftModuleSubdir} + rm -rf $out/${swiftModuleSubdir}/*.swift{module,doc} + # I assume we don't care about .swiftsourceinfo + cp swift/*.swift{module,doc} $out/${swiftModuleSubdir}/ ''; }; diff --git a/pkgs/development/compilers/swift/swiftpm/patches/install-crypto-extras.patch b/pkgs/development/compilers/swift/swiftpm/patches/install-crypto-extras.patch new file mode 100644 index 000000000000..bdbd1c4d596e --- /dev/null +++ b/pkgs/development/compilers/swift/swiftpm/patches/install-crypto-extras.patch @@ -0,0 +1,10 @@ +Install _CryptoExtras target when building with CMake + +--- a/Sources/_CryptoExtras/CMakeLists.txt ++++ b/Sources/_CryptoExtras/CMakeLists.txt +@@ -42,4 +42,5 @@ target_link_options(_CryptoExtras PRIVATE + set_target_properties(_CryptoExtras PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) + ++_install_target(_CryptoExtras) + set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS _CryptoExtras)