@@ -226,22 +226,25 @@ EvalState::EvalState(
226226 */
227227 {CanonPath (store->storeDir ), store->getFSAccessor (settings.pureEval )},
228228 }))
229- , rootFS(({
230- /* In pure eval mode, we provide a filesystem that only
231- contains the Nix store.
232-
233- If we have a chroot store and pure eval is not enabled,
234- use a union accessor to make the chroot store available
235- at its logical location while still having the
236- underlying directory available. This is necessary for
237- instance if we're evaluating a file from the physical
238- /nix/store while using a chroot store. */
239- auto accessor = getFSSourceAccessor ();
240-
241- auto realStoreDir = dirOf (store->toRealPath (StorePath::dummy));
242- if (settings.pureEval || store->storeDir != realStoreDir) {
243- accessor = settings.pureEval ? storeFS.cast <SourceAccessor>() : makeUnionSourceAccessor ({accessor, storeFS});
244- }
229+ , rootFS([&] {
230+ auto accessor = [&]() -> decltype (rootFS) {
231+ /* In pure eval mode, we provide a filesystem that only
232+ contains the Nix store. */
233+ if (settings.pureEval )
234+ return storeFS;
235+
236+ /* If we have a chroot store and pure eval is not enabled,
237+ use a union accessor to make the chroot store available
238+ at its logical location while still having the underlying
239+ directory available. This is necessary for instance if
240+ we're evaluating a file from the physical /nix/store
241+ while using a chroot store. */
242+ auto realStoreDir = dirOf (store->toRealPath (StorePath::dummy));
243+ if (store->storeDir != realStoreDir)
244+ return makeUnionSourceAccessor ({getFSSourceAccessor (), storeFS});
245+
246+ return getFSSourceAccessor ();
247+ }();
245248
246249 /* Apply access control if needed. */
247250 if (settings.restrictEval || settings.pureEval )
@@ -252,8 +255,8 @@ EvalState::EvalState(
252255 throw RestrictedPathError (" access to absolute path '%1%' is forbidden %2%" , path, modeInformation);
253256 });
254257
255- accessor;
256- }))
258+ return accessor;
259+ }( ))
257260 , corepkgsFS(make_ref<MemorySourceAccessor>())
258261 , internalFS(make_ref<MemorySourceAccessor>())
259262 , derivationInternal{corepkgsFS->addFile (
0 commit comments