That works for all but swift, because it wants to be at the root. Wouldn't it make sense to allow for that? Then inside of swift/ it would just be a normal swift package (with Package.swift and the required directory layout). It would just not sit at the root.
It feels like it would not require very big changes in SwiftPM, and the syntax for using such a package could be something like:
That would also make it more clear that such a package would not be allowed to reference files outside it.
I would caution against monorepos like that, though: they make versioning with tags far more complicated and messy. That isn't a reason not to support this, merely a reason not to encourage it.
If this was implemented, Swift Package Manager could use sparse cloning to skip fetching the rest of the repository entirely.
If it would be allowed to use child folder from the repo as url (which is normal for url to points to subfolders), like zano_native_lib_packages/apple at main · hyle-team/zano_native_lib_packages · GitHub,
the parameter subdir or root would not be necessary.
In this case .package() interface will be the same and the uniqueness of the package will still be determined only by the uniqueness of one parameter - the url.
Wouldn't it be easier to implement it this way?
GitLab, for example, allows the repo itself to be arbitrarily deep, so SwiftPM would need to know separately where the .git repo is and which folder within the repo contains the Package.swift.