mirror of
https://github.com/NixOS/nix.git
synced 2025-12-14 04:51:05 +01:00
Make sure settings.sandboxedPaths is closed outside DerivationBuilder
This is a nicer separation of concerns --- `DerivationBuilder` just mounts the extra paths you tell it too, and the outside world is responsible for making sure those extra paths make sense. Since the closure only depends on global settings, and not per-derivation information, we also have the option of moving this up further and caching it across all local builds. (I only just realized this after having done this refactor. I am not doing that change at this time, however.)
This commit is contained in:
parent
08e42e20fa
commit
4c76db8e7c
3 changed files with 27 additions and 17 deletions
|
|
@ -677,9 +677,26 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
|
|||
auto * localStoreP = dynamic_cast<LocalStore *>(&worker.store);
|
||||
assert(localStoreP);
|
||||
|
||||
decltype(DerivationBuilderParams::defaultPathsInChroot) defaultPathsInChroot = settings.sandboxPaths.get();
|
||||
decltype(DerivationBuilderParams::finalEnv) finalEnv;
|
||||
decltype(DerivationBuilderParams::extraFiles) extraFiles;
|
||||
|
||||
/* Add the closure of store paths to the chroot. */
|
||||
StorePathSet closure;
|
||||
for (auto & i : defaultPathsInChroot)
|
||||
try {
|
||||
if (worker.store.isInStore(i.second.source))
|
||||
worker.store.computeFSClosure(worker.store.toStorePath(i.second.source).first, closure);
|
||||
} catch (InvalidPath & e) {
|
||||
} catch (Error & e) {
|
||||
e.addTrace({}, "while processing sandbox path '%s'", i.second.source);
|
||||
throw;
|
||||
}
|
||||
for (auto & i : closure) {
|
||||
auto p = worker.store.printStorePath(i);
|
||||
defaultPathsInChroot.insert_or_assign(p, ChrootPath{.source = p});
|
||||
}
|
||||
|
||||
try {
|
||||
if (drv->structuredAttrs) {
|
||||
auto json = drv->structuredAttrs->prepareStructuredAttrs(
|
||||
|
|
@ -748,6 +765,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
|
|||
*drvOptions,
|
||||
inputPaths,
|
||||
initialOutputs,
|
||||
std::move(defaultPathsInChroot),
|
||||
std::move(finalEnv),
|
||||
std::move(extraFiles),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue