mirror of
https://github.com/NixOS/nix.git
synced 2025-12-09 18:41:03 +01:00
Simplify the definition of rootFS
It was getting very hard to follow.
This commit is contained in:
parent
35189c0ae0
commit
9b2f282af5
1 changed files with 19 additions and 16 deletions
|
|
@ -226,22 +226,25 @@ EvalState::EvalState(
|
||||||
*/
|
*/
|
||||||
{CanonPath(store->storeDir), store->getFSAccessor(settings.pureEval)},
|
{CanonPath(store->storeDir), store->getFSAccessor(settings.pureEval)},
|
||||||
}))
|
}))
|
||||||
, rootFS(({
|
, rootFS([&] {
|
||||||
/* In pure eval mode, we provide a filesystem that only
|
auto accessor = [&]() -> decltype(rootFS) {
|
||||||
contains the Nix store.
|
/* In pure eval mode, we provide a filesystem that only
|
||||||
|
contains the Nix store. */
|
||||||
|
if (settings.pureEval)
|
||||||
|
return storeFS;
|
||||||
|
|
||||||
If we have a chroot store and pure eval is not enabled,
|
/* If we have a chroot store and pure eval is not enabled,
|
||||||
use a union accessor to make the chroot store available
|
use a union accessor to make the chroot store available
|
||||||
at its logical location while still having the
|
at its logical location while still having the underlying
|
||||||
underlying directory available. This is necessary for
|
directory available. This is necessary for instance if
|
||||||
instance if we're evaluating a file from the physical
|
we're evaluating a file from the physical /nix/store
|
||||||
/nix/store while using a chroot store. */
|
while using a chroot store. */
|
||||||
auto accessor = getFSSourceAccessor();
|
auto realStoreDir = dirOf(store->toRealPath(StorePath::dummy));
|
||||||
|
if (store->storeDir != realStoreDir)
|
||||||
|
return makeUnionSourceAccessor({getFSSourceAccessor(), storeFS});
|
||||||
|
|
||||||
auto realStoreDir = dirOf(store->toRealPath(StorePath::dummy));
|
return getFSSourceAccessor();
|
||||||
if (settings.pureEval || store->storeDir != realStoreDir) {
|
}();
|
||||||
accessor = settings.pureEval ? storeFS.cast<SourceAccessor>() : makeUnionSourceAccessor({accessor, storeFS});
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Apply access control if needed. */
|
/* Apply access control if needed. */
|
||||||
if (settings.restrictEval || settings.pureEval)
|
if (settings.restrictEval || settings.pureEval)
|
||||||
|
|
@ -252,8 +255,8 @@ EvalState::EvalState(
|
||||||
throw RestrictedPathError("access to absolute path '%1%' is forbidden %2%", path, modeInformation);
|
throw RestrictedPathError("access to absolute path '%1%' is forbidden %2%", path, modeInformation);
|
||||||
});
|
});
|
||||||
|
|
||||||
accessor;
|
return accessor;
|
||||||
}))
|
}())
|
||||||
, corepkgsFS(make_ref<MemorySourceAccessor>())
|
, corepkgsFS(make_ref<MemorySourceAccessor>())
|
||||||
, internalFS(make_ref<MemorySourceAccessor>())
|
, internalFS(make_ref<MemorySourceAccessor>())
|
||||||
, derivationInternal{corepkgsFS->addFile(
|
, derivationInternal{corepkgsFS->addFile(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue