1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-03 18:41:47 +02:00

Fix findFile(), coerceToPath()

This commit is contained in:
Eelco Dolstra 2022-05-10 16:12:48 +02:00
parent e7f8aa8bdd
commit b4c6adfd35
13 changed files with 92 additions and 80 deletions

View file

@ -89,17 +89,18 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state)
return res.finish();
}
Path lookupFileArg(EvalState & state, std::string_view s)
SourcePath lookupFileArg(EvalState & state, std::string_view s)
{
if (isUri(s)) {
return state.store->toRealPath(
fetchers::downloadTarball(
state.store, resolveUri(s), "source", false).first.storePath);
auto storePath = fetchers::downloadTarball(
state.store, resolveUri(s), "source", false).first.storePath;
auto & accessor = state.registerAccessor(makeFSInputAccessor(state.store->toRealPath(storePath)));
return {accessor, "/"};
} else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') {
Path p(s.substr(1, s.size() - 2));
return state.findFile(p);
} else
return absPath(std::string(s));
return state.rootPath(absPath(std::string(s)));
}
}