mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 14:56:15 +02:00
Improve display of GitHub input filenames in error messages
E.g. … while evaluating the attribute 'buildCommand' of the derivation 'vm-test-run-github-flakes' at «github:NixOS/nixpkgs/2fa57ed190fd6c7c746319444f34b5917666e5c1»/pkgs/stdenv/generic/make-derivation.nix:278:7:
This commit is contained in:
parent
9a9b03b8d6
commit
e17a619106
4 changed files with 24 additions and 9 deletions
|
@ -496,6 +496,8 @@ EvalState::EvalState(
|
||||||
, baseEnv(allocEnv(128))
|
, baseEnv(allocEnv(128))
|
||||||
, staticBaseEnv{std::make_shared<StaticEnv>(false, nullptr)}
|
, staticBaseEnv{std::make_shared<StaticEnv>(false, nullptr)}
|
||||||
{
|
{
|
||||||
|
corepkgsFS->setPathDisplay("<nix", ">");
|
||||||
|
|
||||||
countCalls = getEnv("NIX_COUNT_CALLS").value_or("0") != "0";
|
countCalls = getEnv("NIX_COUNT_CALLS").value_or("0") != "0";
|
||||||
|
|
||||||
assert(gcInitialised);
|
assert(gcInitialised);
|
||||||
|
|
|
@ -232,7 +232,11 @@ struct GitArchiveInputScheme : InputScheme
|
||||||
{
|
{
|
||||||
auto [storePath, input2] = downloadArchive(store, input);
|
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};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,9 @@ static std::atomic<size_t> nextNumber{0};
|
||||||
|
|
||||||
InputAccessor::InputAccessor()
|
InputAccessor::InputAccessor()
|
||||||
: number(++nextNumber)
|
: number(++nextNumber)
|
||||||
{ }
|
, displayPrefix{"/virtual/" + std::to_string(number)}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: merge with archive.cc.
|
// FIXME: merge with archive.cc.
|
||||||
void InputAccessor::dumpPath(
|
void InputAccessor::dumpPath(
|
||||||
|
@ -91,9 +93,15 @@ std::optional<InputAccessor::Stat> InputAccessor::maybeLstat(const CanonPath & p
|
||||||
return lstat(path);
|
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)
|
std::string InputAccessor::showPath(const CanonPath & path)
|
||||||
{
|
{
|
||||||
return "/virtual/" + std::to_string(number) + path.abs();
|
return displayPrefix + path.abs() + displaySuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FSInputAccessorImpl : FSInputAccessor
|
struct FSInputAccessorImpl : FSInputAccessor
|
||||||
|
@ -109,7 +117,9 @@ struct FSInputAccessorImpl : FSInputAccessor
|
||||||
: root(root)
|
: root(root)
|
||||||
, allowedPaths(std::move(allowedPaths))
|
, allowedPaths(std::move(allowedPaths))
|
||||||
, makeNotAllowedError(std::move(makeNotAllowedError))
|
, makeNotAllowedError(std::move(makeNotAllowedError))
|
||||||
{ }
|
{
|
||||||
|
displayPrefix = root.abs();
|
||||||
|
}
|
||||||
|
|
||||||
std::string readFile(const CanonPath & path) override
|
std::string readFile(const CanonPath & path) override
|
||||||
{
|
{
|
||||||
|
@ -201,11 +211,6 @@ struct FSInputAccessorImpl : FSInputAccessor
|
||||||
{
|
{
|
||||||
return (bool) allowedPaths;
|
return (bool) allowedPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string showPath(const CanonPath & path) override
|
|
||||||
{
|
|
||||||
return (root + path).abs();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ref<FSInputAccessor> makeFSInputAccessor(
|
ref<FSInputAccessor> makeFSInputAccessor(
|
||||||
|
|
|
@ -13,6 +13,8 @@ struct InputAccessor : public std::enable_shared_from_this<InputAccessor>
|
||||||
{
|
{
|
||||||
const size_t number;
|
const size_t number;
|
||||||
|
|
||||||
|
std::string displayPrefix, displaySuffix;
|
||||||
|
|
||||||
InputAccessor();
|
InputAccessor();
|
||||||
|
|
||||||
virtual ~InputAccessor()
|
virtual ~InputAccessor()
|
||||||
|
@ -58,6 +60,8 @@ struct InputAccessor : public std::enable_shared_from_this<InputAccessor>
|
||||||
return number < x.number;
|
return number < x.number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPathDisplay(std::string displayPrefix, std::string displaySuffix = "");
|
||||||
|
|
||||||
virtual std::string showPath(const CanonPath & path);
|
virtual std::string showPath(const CanonPath & path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue