diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 94b351819..c448ed07f 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -496,6 +496,8 @@ EvalState::EvalState( , baseEnv(allocEnv(128)) , staticBaseEnv{std::make_shared(false, nullptr)} { + corepkgsFS->setPathDisplay(""); + countCalls = getEnv("NIX_COUNT_CALLS").value_or("0") != "0"; assert(gcInitialised); diff --git a/src/libfetchers/github.cc b/src/libfetchers/github.cc index df782e01c..8756b1937 100644 --- a/src/libfetchers/github.cc +++ b/src/libfetchers/github.cc @@ -232,7 +232,11 @@ struct GitArchiveInputScheme : InputScheme { auto [storePath, input2] = downloadArchive(store, input); - return {makeZipInputAccessor(CanonPath(store->toRealPath(storePath))), input2}; + auto accessor = makeZipInputAccessor(CanonPath(store->toRealPath(storePath))); + + accessor->setPathDisplay("«" + input2.to_string() + "»"); + + return {accessor, input2}; } }; diff --git a/src/libfetchers/input-accessor.cc b/src/libfetchers/input-accessor.cc index ce1327fda..2391124e2 100644 --- a/src/libfetchers/input-accessor.cc +++ b/src/libfetchers/input-accessor.cc @@ -9,7 +9,9 @@ static std::atomic nextNumber{0}; InputAccessor::InputAccessor() : number(++nextNumber) -{ } + , displayPrefix{"/virtual/" + std::to_string(number)} +{ +} // FIXME: merge with archive.cc. void InputAccessor::dumpPath( @@ -91,9 +93,15 @@ std::optional InputAccessor::maybeLstat(const CanonPath & p return lstat(path); } +void InputAccessor::setPathDisplay(std::string displayPrefix, std::string displaySuffix) +{ + this->displayPrefix = std::move(displayPrefix); + this->displaySuffix = std::move(displaySuffix); +} + std::string InputAccessor::showPath(const CanonPath & path) { - return "/virtual/" + std::to_string(number) + path.abs(); + return displayPrefix + path.abs() + displaySuffix; } struct FSInputAccessorImpl : FSInputAccessor @@ -109,7 +117,9 @@ struct FSInputAccessorImpl : FSInputAccessor : root(root) , allowedPaths(std::move(allowedPaths)) , makeNotAllowedError(std::move(makeNotAllowedError)) - { } + { + displayPrefix = root.abs(); + } std::string readFile(const CanonPath & path) override { @@ -201,11 +211,6 @@ struct FSInputAccessorImpl : FSInputAccessor { return (bool) allowedPaths; } - - std::string showPath(const CanonPath & path) override - { - return (root + path).abs(); - } }; ref makeFSInputAccessor( diff --git a/src/libfetchers/input-accessor.hh b/src/libfetchers/input-accessor.hh index 3160eaf28..6b725f86e 100644 --- a/src/libfetchers/input-accessor.hh +++ b/src/libfetchers/input-accessor.hh @@ -13,6 +13,8 @@ struct InputAccessor : public std::enable_shared_from_this { const size_t number; + std::string displayPrefix, displaySuffix; + InputAccessor(); virtual ~InputAccessor() @@ -58,6 +60,8 @@ struct InputAccessor : public std::enable_shared_from_this return number < x.number; } + void setPathDisplay(std::string displayPrefix, std::string displaySuffix = ""); + virtual std::string showPath(const CanonPath & path); };