EDIT: Proposal added: SE-NNNN Add CLI for editing global mirrors configuration by samuelmurray · Pull Request #3265 · swiftlang/swift-evolution · GitHub
Hi! I'm here to pitch an addition to the swift CLI, that lets the user edit and read the global configuration file for swift package manager dependency mirrors. Originally, mirrors could only be configured locally, per project, as described by the original proposal. The file name has since changed, and local mirrors configuration is stored in <project>/.swiftpm/configuration/mirrors.json.
However, support for a global configuration file was added in a later release, mirroring (pun intended) the design of package registries, which has supported local and global configuration since the start. Global configuration files for mirrors and package registries are especially useful in enterprise environment, where certain packages will always be access from a custom URL. The benefit of this is increased even more with the upcoming support for mirroring of binary targets. Global configuration for mirrors is stored in ~/.swiftpm/configuration/mirrors.json.
Unfortunately, there is currently no easy way to edit or view the global mirrors configuration, other than manually creating and editing the file. Chances are most people - as was the case for me until recently - are not even aware that global configuration files are supported.
The CLI for interacting with the local configuration file is
swift package config set-mirrorswift package config unset-mirrorswift package config get-mirror
Taking inspiration from the CLI for package registries, I suggest that we add a --global flag for each of these commands, e.g. swift package config set-mirror --global [...]. All of these commands, when used with this flag, will only consider the global configuration file. By using this flag, the command can be run in any directory, unlike the current (unflagged) command which fails if the current directory (or any of its parents) does not contain a Package.swift file.
The current behaviour of swift package config get-mirror is that if the local configuration files is empty, or doesn't exist, then the global configuration file is read. I propose to leave this behaviour unchanged. To me, it would make more sense if the local and global configuration was merged (with local having higher priority) rather than ignoring all global configuration if any local configuration exists. However, I think such a changed is somewhat unrelated, and could be made as a follow-up proposal to this one.
A draft implementation can be found here: Add --global flag to CLI for editing and viewing shared mirrors configuration by samuelmurray · Pull Request #9950 · swiftlang/swift-package-manager · GitHub