diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-03-10 15:48:14 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2022-03-10 15:48:14 +0000 |
commit | 8ba089597fa19bfd49ba5f22a5e821740ca4eb5d (patch) | |
tree | b4f2299b9c973ef7636f8ce1bab0299dee4cc389 /src/nix/prefetch.cc | |
parent | 13b6b645897fd2edaa0f09fa48d6fe8dd6287b55 (diff) | |
parent | 4d98143914120d0163f5c50f30ce8a5289433f8f (diff) |
Merge remote-tracking branch 'upstream/master' into path-info
Diffstat (limited to 'src/nix/prefetch.cc')
-rw-r--r-- | src/nix/prefetch.cc | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc index c13603d42..35faa7a88 100644 --- a/src/nix/prefetch.cc +++ b/src/nix/prefetch.cc @@ -16,7 +16,7 @@ using namespace nix; /* If ‘url’ starts with ‘mirror://’, then resolve it using the list of mirrors defined in Nixpkgs. */ -string resolveMirrorUrl(EvalState & state, string url) +std::string resolveMirrorUrl(EvalState & state, const std::string & url) { if (url.substr(0, 9) != "mirror://") return url; @@ -28,18 +28,18 @@ string resolveMirrorUrl(EvalState & state, string url) Value vMirrors; // FIXME: use nixpkgs flake state.eval(state.parseExprFromString("import <nixpkgs/pkgs/build-support/fetchurl/mirrors.nix>", "."), vMirrors); - state.forceAttrs(vMirrors); + state.forceAttrs(vMirrors, noPos); auto mirrorList = vMirrors.attrs->find(state.symbols.create(mirrorName)); if (mirrorList == vMirrors.attrs->end()) throw Error("unknown mirror name '%s'", mirrorName); - state.forceList(*mirrorList->value); + state.forceList(*mirrorList->value, noPos); if (mirrorList->value->listSize() < 1) throw Error("mirror URL '%s' did not expand to anything", url); - auto mirror = state.forceString(*mirrorList->value->listElems()[0]); - return mirror + (hasSuffix(mirror, "/") ? "" : "/") + string(s, p + 1); + std::string mirror(state.forceString(*mirrorList->value->listElems()[0])); + return mirror + (hasSuffix(mirror, "/") ? "" : "/") + s.substr(p + 1); } std::tuple<StorePath, Hash> prefetchFile( @@ -134,10 +134,10 @@ static int main_nix_prefetch_url(int argc, char * * argv) { { HashType ht = htSHA256; - std::vector<string> args; + std::vector<std::string> args; bool printPath = getEnv("PRINT_PATH") == "1"; bool fromExpr = false; - string attrPath; + std::string attrPath; bool unpack = false; bool executable = false; std::optional<std::string> name; @@ -153,7 +153,7 @@ static int main_nix_prefetch_url(int argc, char * * argv) else if (*arg == "--version") printVersion("nix-prefetch-url"); else if (*arg == "--type") { - string s = getArg(*arg, arg, end); + auto s = getArg(*arg, arg, end); ht = parseHashType(s); } else if (*arg == "--print-path") @@ -192,7 +192,7 @@ static int main_nix_prefetch_url(int argc, char * * argv) /* If -A is given, get the URL from the specified Nix expression. */ - string url; + std::string url; if (!fromExpr) { if (args.empty()) throw UsageError("you must specify a URL"); @@ -202,11 +202,11 @@ static int main_nix_prefetch_url(int argc, char * * argv) Value vRoot; state->evalFile(path, vRoot); Value & v(*findAlongAttrPath(*state, attrPath, autoArgs, vRoot).first); - state->forceAttrs(v); + state->forceAttrs(v, noPos); /* Extract the URL. */ auto & attr = v.attrs->need(state->symbols.create("urls")); - state->forceList(*attr.value); + state->forceList(*attr.value, noPos); if (attr.value->listSize() < 1) throw Error("'urls' list is empty"); url = state->forceString(*attr.value->listElems()[0]); |