diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-10-06 17:19:27 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-10-06 17:19:27 +0200 |
commit | 46753b5e9ca33b41273ac5815e502921008e7fb5 (patch) | |
tree | 5c51b93b57a89c0ca91bb9066a1baa050cffc0d1 /src/libexpr/primops/fetchTree.cc | |
parent | f45b30de2f3e6ce8bfab999b0272e22da06491b3 (diff) | |
parent | 7cdaae6b9cc3ef5b64bbd7fd2776fa5e7572aa8d (diff) |
Merge branch 'considerate/scp-like-urls' of https://github.com/considerate/nix
Diffstat (limited to 'src/libexpr/primops/fetchTree.cc')
-rw-r--r-- | src/libexpr/primops/fetchTree.cc | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/libexpr/primops/fetchTree.cc b/src/libexpr/primops/fetchTree.cc index 06bdec003..8ab9049a6 100644 --- a/src/libexpr/primops/fetchTree.cc +++ b/src/libexpr/primops/fetchTree.cc @@ -81,10 +81,24 @@ std::string fixURIForGit(std::string uri, EvalState & state) return fixURI(uri, state); } -void addURI(EvalState &state, fetchers::Attrs &attrs, Symbol name, std::string v) -{ +void addURI( + EvalState &state, + fetchers::Attrs &attrs, + Symbol name, + std::string v, + const std::optional<std::string> type +) { string n(name); - attrs.emplace(name, n == "url" ? fixURI(v, state) : v); + if (n == "url") { + if (type == "git") { + attrs.emplace("type", "git"); + attrs.emplace(name, fixURIForGit(v, state)); + } else { + attrs.emplace(name, fixURI(v, state)); + } + } else { + attrs.emplace(name, v); + } } struct FetchTreeParams { @@ -117,10 +131,9 @@ static void fetchTree( state, attrs, attr.name, - state.coerceToString(*attr.pos, *attr.value, context, false, false) + state.coerceToString(*attr.pos, *attr.value, context, false, false), + type ); - else if (attr.value->type() == nString) - addURI(state, attrs, attr.name, attr.value->string.s); else if (attr.value->type() == nBool) attrs.emplace(attr.name, Explicit<bool>{attr.value->boolean}); else if (attr.value->type() == nInt) |