aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorKalle Jepsen <git@ksonj.net>2021-11-17 08:41:26 +0100
committerKalle Jepsen <git@ksonj.net>2021-11-17 08:41:26 +0100
commit6d46b5b609f8f85968e1ca7aaf7c57dd52d0521c (patch)
tree05e67ce986d19e64086cea18ee91ba3bc96b7c7f /src/libexpr
parent8c93a481af2ce8fbcdb9e2bbcc9559d52703112f (diff)
Fix detection of scp-style URIs to support non-standard SSH ports for git
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/primops/fetchTree.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libexpr/primops/fetchTree.cc b/src/libexpr/primops/fetchTree.cc
index e6becdafc..b307ac04a 100644
--- a/src/libexpr/primops/fetchTree.cc
+++ b/src/libexpr/primops/fetchTree.cc
@@ -74,8 +74,11 @@ std::string fixURI(std::string uri, EvalState & state, const std::string & defau
std::string fixURIForGit(std::string uri, EvalState & state)
{
+ /* Detects scp-style uris (e.g. git@github.com:NixOS/nix) and fixes
+ * them by removing the `:` and assuming a scheme of `ssh://`
+ * */
static std::regex scp_uri("([^/].*)@(.*):(.*)");
- if (uri[0] != '/' && std::regex_match(uri, scp_uri))
+ if (uri[0] != '/' && std::regex_match(uri, scp_uri) && uri.find("://") == std::string::npos)
return fixURI(std::regex_replace(uri, scp_uri, "$1@$2/$3"), state, "ssh");
else
return fixURI(uri, state);