mirror of
https://github.com/NixOS/nix.git
synced 2025-11-29 21:50:58 +01:00
Mount flake input source accessors on top of storeFS
This way, we don't need the PathDisplaySourceAccessor source accessor hack, since error messages are produced directly by the original source accessor. In fact, we don't even need to copy the inputs to the store at all, so this gets us very close to lazy trees. We just need to know the store path so that requires hashing the entire input, which isn't lazy. But the next step will be to use a virtual store path that gets rewritten to the actual store path only when needed.
This commit is contained in:
parent
fcddf4afe3
commit
73b1754816
14 changed files with 66 additions and 117 deletions
|
|
@ -14,8 +14,8 @@
|
|||
#include "profiles.hh"
|
||||
#include "print.hh"
|
||||
#include "filtering-source-accessor.hh"
|
||||
#include "forwarding-source-accessor.hh"
|
||||
#include "memory-source-accessor.hh"
|
||||
#include "mounted-source-accessor.hh"
|
||||
#include "gc-small-vector.hh"
|
||||
#include "url.hh"
|
||||
#include "fetch-to-store.hh"
|
||||
|
|
@ -181,34 +181,6 @@ static Symbol getName(const AttrName & name, EvalState & state, Env & env)
|
|||
}
|
||||
}
|
||||
|
||||
struct PathDisplaySourceAccessor : ForwardingSourceAccessor
|
||||
{
|
||||
ref<EvalState::StorePathAccessors> storePathAccessors;
|
||||
|
||||
PathDisplaySourceAccessor(
|
||||
ref<SourceAccessor> next,
|
||||
ref<EvalState::StorePathAccessors> storePathAccessors)
|
||||
: ForwardingSourceAccessor(next)
|
||||
, storePathAccessors(storePathAccessors)
|
||||
{
|
||||
}
|
||||
|
||||
std::string showPath(const CanonPath & path) override
|
||||
{
|
||||
/* Find the accessor that produced `path`, if any, and use it
|
||||
to render a more informative path
|
||||
(e.g. `«github:foo/bar»/flake.nix` rather than
|
||||
`/nix/store/hash.../flake.nix`). */
|
||||
auto ub = storePathAccessors->upper_bound(path);
|
||||
if (ub != storePathAccessors->begin())
|
||||
ub--;
|
||||
if (ub != storePathAccessors->end() && path.isWithin(ub->first))
|
||||
return ub->second->showPath(path.removePrefix(ub->first));
|
||||
else
|
||||
return next->showPath(path);
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr size_t BASE_ENV_SIZE = 128;
|
||||
|
||||
EvalState::EvalState(
|
||||
|
|
@ -274,7 +246,12 @@ EvalState::EvalState(
|
|||
}
|
||||
, repair(NoRepair)
|
||||
, emptyBindings(0)
|
||||
, storePathAccessors(make_ref<StorePathAccessors>())
|
||||
, storeFS(
|
||||
makeMountedSourceAccessor(
|
||||
{
|
||||
{CanonPath::root, makeEmptySourceAccessor()},
|
||||
{CanonPath(store->storeDir), makeFSSourceAccessor(dirOf(store->toRealPath(StorePath::dummy)))}
|
||||
}))
|
||||
, rootFS(
|
||||
({
|
||||
/* In pure eval mode, we provide a filesystem that only
|
||||
|
|
@ -290,18 +267,11 @@ EvalState::EvalState(
|
|||
|
||||
auto realStoreDir = dirOf(store->toRealPath(StorePath::dummy));
|
||||
if (settings.pureEval || store->storeDir != realStoreDir) {
|
||||
auto storeFS = makeMountedSourceAccessor(
|
||||
{
|
||||
{CanonPath::root, makeEmptySourceAccessor()},
|
||||
{CanonPath(store->storeDir), makeFSSourceAccessor(realStoreDir)}
|
||||
});
|
||||
accessor = settings.pureEval
|
||||
? storeFS
|
||||
? storeFS.cast<SourceAccessor>()
|
||||
: makeUnionSourceAccessor({accessor, storeFS});
|
||||
}
|
||||
|
||||
accessor = make_ref<PathDisplaySourceAccessor>(accessor, storePathAccessors);
|
||||
|
||||
/* Apply access control if needed. */
|
||||
if (settings.restrictEval || settings.pureEval)
|
||||
accessor = AllowListSourceAccessor::create(accessor, {}, {},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue