1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 06:31:14 +02:00

Move DerivationBuilder to its own file/header

The building logic is now free of the scheduling logic!

(The interface between them is just what is in the new header. This
makes it much easier to audit, and shrink over time.)
This commit is contained in:
John Ericson 2025-03-16 23:50:48 -04:00
parent 6c2a7fdc49
commit 9792d6bbd9
9 changed files with 142 additions and 6798 deletions

View file

@ -284,6 +284,8 @@
''^src/libstore/build/goal\.cc$'' ''^src/libstore/build/goal\.cc$''
''^src/libstore/include/nix/store/build/goal\.hh$'' ''^src/libstore/include/nix/store/build/goal\.hh$''
''^src/libstore/unix/build/hook-instance\.cc$'' ''^src/libstore/unix/build/hook-instance\.cc$''
''^src/libstore/unix/build/derivation-builder\.cc$''
''^src/libstore/unix/include/nix/store/build/derivation-builder\.hh$''
''^src/libstore/unix/build/local-derivation-goal\.cc$'' ''^src/libstore/unix/build/local-derivation-goal\.cc$''
''^src/libstore/unix/include/nix/store/build/local-derivation-goal\.hh$'' ''^src/libstore/unix/include/nix/store/build/local-derivation-goal\.hh$''
''^src/libstore/build/substitution-goal\.cc$'' ''^src/libstore/build/substitution-goal\.cc$''

View file

@ -0,0 +1,52 @@
#pragma once
/**
* @file Misc type defitions for both local building and remote (RPC building)
*/
#include "nix/util/hash.hh"
#include "nix/store/path.hh"
namespace nix {
class Store;
/**
* Unless we are repairing, we don't both to test validity and just assume it,
* so the choices are `Absent` or `Valid`.
*/
enum struct PathStatus {
Corrupt,
Absent,
Valid,
};
struct InitialOutputStatus
{
StorePath path;
PathStatus status;
/**
* Valid in the store, and additionally non-corrupt if we are repairing
*/
bool isValid() const
{
return status == PathStatus::Valid;
}
/**
* Merely present, allowed to be corrupt
*/
bool isPresent() const
{
return status == PathStatus::Corrupt || status == PathStatus::Valid;
}
};
struct InitialOutput
{
bool wanted;
Hash outputHash;
std::optional<InitialOutputStatus> known;
};
void runPostBuildHook(Store & store, Logger & logger, const StorePath & drvPath, const StorePathSet & outputPaths);
}

View file

@ -4,9 +4,7 @@
#include "nix/store/parsed-derivations.hh" #include "nix/store/parsed-derivations.hh"
#include "nix/store/derivations.hh" #include "nix/store/derivations.hh"
#include "nix/store/derivation-options.hh" #include "nix/store/derivation-options.hh"
#ifndef _WIN32 #include "nix/store/build/derivation-building-misc.hh"
# include "nix/store/user-lock.hh"
#endif
#include "nix/store/outputs-spec.hh" #include "nix/store/outputs-spec.hh"
#include "nix/store/store-api.hh" #include "nix/store/store-api.hh"
#include "nix/store/pathlocks.hh" #include "nix/store/pathlocks.hh"
@ -22,40 +20,6 @@ struct HookInstance;
typedef enum {rpAccept, rpDecline, rpPostpone} HookReply; typedef enum {rpAccept, rpDecline, rpPostpone} HookReply;
/**
* Unless we are repairing, we don't both to test validity and just assume it,
* so the choices are `Absent` or `Valid`.
*/
enum struct PathStatus {
Corrupt,
Absent,
Valid,
};
struct InitialOutputStatus {
StorePath path;
PathStatus status;
/**
* Valid in the store, and additionally non-corrupt if we are repairing
*/
bool isValid() const {
return status == PathStatus::Valid;
}
/**
* Merely present, allowed to be corrupt
*/
bool isPresent() const {
return status == PathStatus::Corrupt
|| status == PathStatus::Valid;
}
};
struct InitialOutput {
bool wanted;
Hash outputHash;
std::optional<InitialOutputStatus> known;
};
/** Used internally */ /** Used internally */
void runPostBuildHook( void runPostBuildHook(
Store & store, Store & store,
@ -308,6 +272,4 @@ struct DerivationGoal : public Goal
}; };
}; };
MakeError(NotDeterministic, BuildError);
} }

View file

@ -13,6 +13,7 @@ headers = [config_pub_h] + files(
'binary-cache-store.hh', 'binary-cache-store.hh',
'build-result.hh', 'build-result.hh',
'build/derivation-goal.hh', 'build/derivation-goal.hh',
'build/derivation-building-misc.hh',
'build/drv-output-substitution-goal.hh', 'build/drv-output-substitution-goal.hh',
'build/goal.hh', 'build/goal.hh',
'build/substitution-goal.hh', 'build/substitution-goal.hh',

View file

@ -1,4 +1,4 @@
#include "nix/store/build/local-derivation-goal.hh" #include "nix/store/build/derivation-builder.hh"
#include "nix/store/local-store.hh" #include "nix/store/local-store.hh"
#include "nix/util/processes.hh" #include "nix/util/processes.hh"
#include "nix/store/indirect-root-store.hh" #include "nix/store/indirect-root-store.hh"
@ -22,7 +22,6 @@
#include "nix/store/posix-fs-canonicalise.hh" #include "nix/store/posix-fs-canonicalise.hh"
#include "nix/util/posix-source-accessor.hh" #include "nix/util/posix-source-accessor.hh"
#include "nix/store/restricted-store.hh" #include "nix/store/restricted-store.hh"
#include "nix/store/config.hh"
#include <queue> #include <queue>
@ -80,106 +79,7 @@ extern "C" int sandbox_init_with_parameters(const char *profile, uint64_t flags,
namespace nix { namespace nix {
/** MakeError(NotDeterministic, BuildError);
* Parameters by (mostly) `const` reference for `DerivationBuilder`.
*/
struct DerivationBuilderParams
{
/** The path of the derivation. */
const StorePath & drvPath;
BuildResult & buildResult;
/**
* The derivation stored at drvPath.
*
* @todo Remove double indirection by delaying when this is
* initialized.
*/
const std::unique_ptr<Derivation> & drv;
const std::unique_ptr<StructuredAttrs> & parsedDrv;
const std::unique_ptr<DerivationOptions> & drvOptions;
// The remainder is state held during the build.
/**
* All input paths (that is, the union of FS closures of the
* immediate input paths).
*/
const StorePathSet & inputPaths;
/**
* @note we do in fact mutate this
*/
std::map<std::string, InitialOutput> & initialOutputs;
const BuildMode & buildMode;
DerivationBuilderParams(
const StorePath & drvPath,
const BuildMode & buildMode,
BuildResult & buildResult,
const std::unique_ptr<Derivation> & drv,
const std::unique_ptr<StructuredAttrs> & parsedDrv,
const std::unique_ptr<DerivationOptions> & drvOptions,
const StorePathSet & inputPaths,
std::map<std::string, InitialOutput> & initialOutputs)
: drvPath{drvPath}
, buildResult{buildResult}
, drv{drv}
, parsedDrv{parsedDrv}
, drvOptions{drvOptions}
, inputPaths{inputPaths}
, initialOutputs{initialOutputs}
, buildMode{buildMode}
{ }
DerivationBuilderParams(DerivationBuilderParams &&) = default;
};
/**
* Callbacks that `DerivationBuilder` needs.
*/
struct DerivationBuilderCallbacks
{
/**
* Open a log file and a pipe to it.
*/
virtual Path openLogFile() = 0;
/**
* Close the log file.
*/
virtual void closeLogFile() = 0;
/**
* Aborts if any output is not valid or corrupt, and otherwise
* returns a 'SingleDrvOutputs' structure containing all outputs.
*
* @todo Probably should just be in `DerivationGoal`.
*/
virtual SingleDrvOutputs assertPathValidity() = 0;
virtual void appendLogTailErrorMsg(std::string & msg) = 0;
/**
* Hook up `builderOut` to some mechanism to ingest the log
*
* @todo this should be reworked
*/
virtual void childStarted() = 0;
/**
* @todo this should be reworked
*/
virtual void childTerminated() = 0;
virtual void noteHashMismatch(void) = 0;
virtual void noteCheckMismatch(void) = 0;
virtual void markContentsGood(const StorePath & path) = 0;
};
/** /**
* This class represents the state for building locally. * This class represents the state for building locally.
@ -192,7 +92,7 @@ struct DerivationBuilderCallbacks
* rather than incoming call edges that either should be removed, or * rather than incoming call edges that either should be removed, or
* become (higher order) function parameters. * become (higher order) function parameters.
*/ */
class DerivationBuilder : public RestrictionContext, DerivationBuilderParams class DerivationBuilderImpl : public DerivationBuilder, DerivationBuilderParams
{ {
Store & store; Store & store;
@ -200,7 +100,7 @@ class DerivationBuilder : public RestrictionContext, DerivationBuilderParams
public: public:
DerivationBuilder( DerivationBuilderImpl(
Store & store, Store & store,
DerivationBuilderCallbacks & miscMethods, DerivationBuilderCallbacks & miscMethods,
DerivationBuilderParams params) DerivationBuilderParams params)
@ -211,16 +111,6 @@ public:
LocalStore & getLocalStore(); LocalStore & getLocalStore();
/**
* User selected for running the builder.
*/
std::unique_ptr<UserLock> buildUser;
/**
* The process ID of the builder.
*/
Pid pid;
private: private:
/** /**
@ -244,16 +134,6 @@ private:
*/ */
Path tmpDirInSandbox; Path tmpDirInSandbox;
public:
/**
* Master side of the pseudoterminal used for the builder's
* standard output/error.
*/
AutoCloseFD builderOut;
private:
/** /**
* Pipe for synchronising updates to the builder namespaces. * Pipe for synchronising updates to the builder namespaces.
*/ */
@ -304,17 +184,17 @@ private:
: source(source), optional(optional) : source(source), optional(optional)
{ } { }
}; };
typedef map<Path, ChrootPath> PathsInChroot; // maps target path to source path typedef std::map<Path, ChrootPath> PathsInChroot; // maps target path to source path
PathsInChroot pathsInChroot; PathsInChroot pathsInChroot;
typedef map<std::string, std::string> Environment; typedef std::map<std::string, std::string> Environment;
Environment env; Environment env;
/** /**
* Hash rewriting. * Hash rewriting.
*/ */
StringMap inputRewrites, outputRewrites; StringMap inputRewrites, outputRewrites;
typedef map<StorePath, StorePath> RedirectedOutputs; typedef std::map<StorePath, StorePath> RedirectedOutputs;
RedirectedOutputs redirectedOutputs; RedirectedOutputs redirectedOutputs;
/** /**
@ -386,12 +266,12 @@ public:
* @returns true if successful, false if we could not acquire a build * @returns true if successful, false if we could not acquire a build
* user. In that case, the caller must wait and then try again. * user. In that case, the caller must wait and then try again.
*/ */
bool prepareBuild(); bool prepareBuild() override;
/** /**
* Start building a derivation. * Start building a derivation.
*/ */
void startBuilder(); void startBuilder() override;;
/** /**
* Tear down build environment after the builder exits (either on * Tear down build environment after the builder exits (either on
@ -402,7 +282,7 @@ public:
* more information. The second case indicates success, and * more information. The second case indicates success, and
* realisations for each output of the derivation are returned. * realisations for each output of the derivation are returned.
*/ */
std::variant<std::pair<BuildResult::Status, Error>, SingleDrvOutputs> unprepareBuild(); std::variant<std::pair<BuildResult::Status, Error>, SingleDrvOutputs> unprepareBuild() override;
private: private:
@ -437,7 +317,7 @@ public:
* Stop the in-process nix daemon thread. * Stop the in-process nix daemon thread.
* @see startDaemon * @see startDaemon
*/ */
void stopDaemon(); void stopDaemon() override;
private: private:
@ -471,13 +351,13 @@ public:
/** /**
* Delete the temporary directory, if we have one. * Delete the temporary directory, if we have one.
*/ */
void deleteTmpDir(bool force); void deleteTmpDir(bool force) override;
/** /**
* Kill any processes running under the build user UID or in the * Kill any processes running under the build user UID or in the
* cgroup of the build. * cgroup of the build.
*/ */
void killSandbox(bool getStats); void killSandbox(bool getStats) override;
private: private:
@ -500,112 +380,15 @@ private:
StorePath makeFallbackPath(OutputNameView outputName); StorePath makeFallbackPath(OutputNameView outputName);
}; };
/** std::unique_ptr<DerivationBuilder> makeDerivationBuilder(
* This hooks up `DerivationBuilder` to the scheduler / goal machinary. Store & store,
* DerivationBuilderCallbacks & miscMethods,
* @todo Eventually, this shouldn't exist, because `DerivationGoal` can DerivationBuilderParams params)
* just choose to use `DerivationBuilder` or its remote-building
* equalivalent directly, at the "value level" rather than "class
* inheritance hierarchy" level.
*/
struct LocalDerivationGoal : DerivationGoal, DerivationBuilderCallbacks
{ {
DerivationBuilder builder; return std::make_unique<DerivationBuilderImpl>(
store,
LocalDerivationGoal(const StorePath & drvPath, miscMethods,
const OutputsSpec & wantedOutputs, Worker & worker, std::move(params));
BuildMode buildMode)
: DerivationGoal{drvPath, wantedOutputs, worker, buildMode}
, builder{
worker.store,
static_cast<DerivationBuilderCallbacks &>(*this),
DerivationBuilderParams {
DerivationGoal::drvPath,
DerivationGoal::buildMode,
DerivationGoal::buildResult,
DerivationGoal::drv,
DerivationGoal::parsedDrv,
DerivationGoal::drvOptions,
DerivationGoal::inputPaths,
DerivationGoal::initialOutputs,
},
}
{}
LocalDerivationGoal(const StorePath & drvPath, const BasicDerivation & drv,
const OutputsSpec & wantedOutputs, Worker & worker,
BuildMode buildMode = bmNormal)
: DerivationGoal{drvPath, drv, wantedOutputs, worker, buildMode}
, builder{
worker.store,
static_cast<DerivationBuilderCallbacks &>(*this),
DerivationBuilderParams {
DerivationGoal::drvPath,
DerivationGoal::buildMode,
DerivationGoal::buildResult,
DerivationGoal::drv,
DerivationGoal::parsedDrv,
DerivationGoal::drvOptions,
DerivationGoal::inputPaths,
DerivationGoal::initialOutputs,
},
}
{}
virtual ~LocalDerivationGoal() override;
/**
* The additional states.
*/
Goal::Co tryLocalBuild() override;
bool isReadDesc(int fd) override;
/**
* Forcibly kill the child process, if any.
*
* Called by destructor, can't be overridden
*/
void killChild() override final;
void childStarted() override;
void childTerminated() override;
void noteHashMismatch(void) override;
void noteCheckMismatch(void) override;
void markContentsGood(const StorePath &) override;
// Fake overrides to instantiate identically-named virtual methods
Path openLogFile() override {
return DerivationGoal::openLogFile();
}
void closeLogFile() override {
DerivationGoal::closeLogFile();
}
SingleDrvOutputs assertPathValidity() override {
return DerivationGoal::assertPathValidity();
}
void appendLogTailErrorMsg(std::string & msg) override {
DerivationGoal::appendLogTailErrorMsg(msg);
}
};
std::shared_ptr<DerivationGoal> makeLocalDerivationGoal(
const StorePath & drvPath,
const OutputsSpec & wantedOutputs, Worker & worker,
BuildMode buildMode)
{
return std::make_shared<LocalDerivationGoal>(drvPath, wantedOutputs, worker, buildMode);
}
std::shared_ptr<DerivationGoal> makeLocalDerivationGoal(
const StorePath & drvPath, const BasicDerivation & drv,
const OutputsSpec & wantedOutputs, Worker & worker,
BuildMode buildMode)
{
return std::make_shared<LocalDerivationGoal>(drvPath, drv, wantedOutputs, worker, buildMode);
} }
void handleDiffHook( void handleDiffHook(
@ -642,20 +425,10 @@ void handleDiffHook(
} }
} }
const Path DerivationBuilder::homeDir = "/homeless-shelter"; const Path DerivationBuilderImpl::homeDir = "/homeless-shelter";
LocalDerivationGoal::~LocalDerivationGoal() inline bool DerivationBuilderImpl::needsHashRewrite()
{
/* Careful: we should never ever throw an exception from a
destructor. */
try { builder.deleteTmpDir(false); } catch (...) { ignoreExceptionInDestructor(); }
try { killChild(); } catch (...) { ignoreExceptionInDestructor(); }
try { builder.stopDaemon(); } catch (...) { ignoreExceptionInDestructor(); }
}
inline bool DerivationBuilder::needsHashRewrite()
{ {
#ifdef __linux__ #ifdef __linux__
return !useChroot; return !useChroot;
@ -666,7 +439,7 @@ inline bool DerivationBuilder::needsHashRewrite()
} }
LocalStore & DerivationBuilder::getLocalStore() LocalStore & DerivationBuilderImpl::getLocalStore()
{ {
auto p = dynamic_cast<LocalStore *>(&store); auto p = dynamic_cast<LocalStore *>(&store);
assert(p); assert(p);
@ -674,28 +447,7 @@ LocalStore & DerivationBuilder::getLocalStore()
} }
void LocalDerivationGoal::killChild() void DerivationBuilderImpl::killSandbox(bool getStats)
{
if (builder.pid != -1) {
worker.childTerminated(this);
/* If we're using a build user, then there is a tricky race
condition: if we kill the build user before the child has
done its setuid() to the build user uid, then it won't be
killed, and we'll potentially lock up in pid.wait(). So
also send a conventional kill to the child. */
::kill(-builder.pid, SIGKILL); /* ignore the result */
builder.killSandbox(true);
builder.pid.wait();
}
DerivationGoal::killChild();
}
void DerivationBuilder::killSandbox(bool getStats)
{ {
if (cgroup) { if (cgroup) {
#ifdef __linux__ #ifdef __linux__
@ -717,91 +469,7 @@ void DerivationBuilder::killSandbox(bool getStats)
} }
void LocalDerivationGoal::childStarted() bool DerivationBuilderImpl::prepareBuild()
{
worker.childStarted(shared_from_this(), {builder.builderOut.get()}, true, true);
}
void LocalDerivationGoal::childTerminated()
{
worker.childTerminated(this);
}
void LocalDerivationGoal::noteHashMismatch()
{
worker.hashMismatch = true;
}
void LocalDerivationGoal::noteCheckMismatch()
{
worker.checkMismatch = true;
}
void LocalDerivationGoal::markContentsGood(const StorePath & path)
{
worker.markContentsGood(path);
}
Goal::Co LocalDerivationGoal::tryLocalBuild()
{
assert(!hook);
unsigned int curBuilds = worker.getNrLocalBuilds();
if (curBuilds >= settings.maxBuildJobs) {
outputLocks.unlock();
co_await waitForBuildSlot();
co_return tryToBuild();
}
if (!builder.prepareBuild()) {
if (!actLock)
actLock = std::make_unique<Activity>(*logger, lvlWarn, actBuildWaiting,
fmt("waiting for a free build user ID for '%s'", Magenta(worker.store.printStorePath(drvPath))));
co_await waitForAWhile();
co_return tryLocalBuild();
}
actLock.reset();
try {
/* Okay, we have to build. */
builder.startBuilder();
} catch (BuildError & e) {
outputLocks.unlock();
builder.buildUser.reset();
worker.permanentFailure = true;
co_return done(BuildResult::InputRejected, {}, std::move(e));
}
started();
co_await Suspend{};
trace("build done");
auto res = builder.unprepareBuild();
// N.B. cannot use `std::visit` with co-routine return
if (auto * ste = std::get_if<0>(&res)) {
outputLocks.unlock();
co_return done(std::move(ste->first), {}, std::move(ste->second));
} else if (auto * builtOutputs = std::get_if<1>(&res)) {
/* It is now safe to delete the lock files, since all future
lockers will see that the output paths are valid; they will
not create new lock files with the same names as the old
(unlinked) lock files. */
outputLocks.setDeletion(true);
outputLocks.unlock();
co_return done(BuildResult::Built, std::move(*builtOutputs));
} else {
unreachable();
}
}
bool DerivationBuilder::prepareBuild()
{ {
/* Cache this */ /* Cache this */
derivationType = drv->type(); derivationType = drv->type();
@ -858,7 +526,7 @@ bool DerivationBuilder::prepareBuild()
} }
std::variant<std::pair<BuildResult::Status, Error>, SingleDrvOutputs> DerivationBuilder::unprepareBuild() std::variant<std::pair<BuildResult::Status, Error>, SingleDrvOutputs> DerivationBuilderImpl::unprepareBuild()
{ {
Finally releaseBuildUser([&](){ Finally releaseBuildUser([&](){
/* Release the build user at the end of this function. We don't do /* Release the build user at the end of this function. We don't do
@ -996,7 +664,7 @@ static void movePath(const Path & src, const Path & dst)
extern void replaceValidPath(const Path & storePath, const Path & tmpPath); extern void replaceValidPath(const Path & storePath, const Path & tmpPath);
bool DerivationBuilder::cleanupDecideWhetherDiskFull() bool DerivationBuilderImpl::cleanupDecideWhetherDiskFull()
{ {
bool diskFull = false; bool diskFull = false;
@ -1089,7 +757,7 @@ static void rethrowExceptionAsError()
/** /**
* Send the current exception to the parent in the format expected by * Send the current exception to the parent in the format expected by
* `DerivationBuilder::processSandboxSetupMessages()`. * `DerivationBuilderImpl::processSandboxSetupMessages()`.
*/ */
static void handleChildException(bool sendException) static void handleChildException(bool sendException)
{ {
@ -1106,7 +774,7 @@ static void handleChildException(bool sendException)
} }
} }
void DerivationBuilder::startBuilder() void DerivationBuilderImpl::startBuilder()
{ {
if ((buildUser && buildUser->getUIDCount() != 1) if ((buildUser && buildUser->getUIDCount() != 1)
#ifdef __linux__ #ifdef __linux__
@ -1723,7 +1391,7 @@ void DerivationBuilder::startBuilder()
} }
void DerivationBuilder::processSandboxSetupMessages() void DerivationBuilderImpl::processSandboxSetupMessages()
{ {
std::vector<std::string> msgs; std::vector<std::string> msgs;
while (true) { while (true) {
@ -1752,7 +1420,7 @@ void DerivationBuilder::processSandboxSetupMessages()
} }
void DerivationBuilder::initTmpDir() void DerivationBuilderImpl::initTmpDir()
{ {
/* In a sandbox, for determinism, always use the same temporary /* In a sandbox, for determinism, always use the same temporary
directory. */ directory. */
@ -1796,7 +1464,7 @@ void DerivationBuilder::initTmpDir()
} }
void DerivationBuilder::initEnv() void DerivationBuilderImpl::initEnv()
{ {
env.clear(); env.clear();
@ -1864,7 +1532,7 @@ void DerivationBuilder::initEnv()
} }
void DerivationBuilder::writeStructuredAttrs() void DerivationBuilderImpl::writeStructuredAttrs()
{ {
if (parsedDrv) { if (parsedDrv) {
auto json = parsedDrv->prepareStructuredAttrs( auto json = parsedDrv->prepareStructuredAttrs(
@ -1893,7 +1561,7 @@ void DerivationBuilder::writeStructuredAttrs()
} }
void DerivationBuilder::startDaemon() void DerivationBuilderImpl::startDaemon()
{ {
experimentalFeatureSettings.require(Xp::RecursiveNix); experimentalFeatureSettings.require(Xp::RecursiveNix);
@ -1961,7 +1629,7 @@ void DerivationBuilder::startDaemon()
} }
void DerivationBuilder::stopDaemon() void DerivationBuilderImpl::stopDaemon()
{ {
if (daemonSocket && shutdown(daemonSocket.get(), SHUT_RDWR) == -1) { if (daemonSocket && shutdown(daemonSocket.get(), SHUT_RDWR) == -1) {
// According to the POSIX standard, the 'shutdown' function should // According to the POSIX standard, the 'shutdown' function should
@ -1994,7 +1662,7 @@ void DerivationBuilder::stopDaemon()
} }
void DerivationBuilder::addDependency(const StorePath & path) void DerivationBuilderImpl::addDependency(const StorePath & path)
{ {
if (isAllowed(path)) return; if (isAllowed(path)) return;
@ -2046,7 +1714,7 @@ void DerivationBuilder::addDependency(const StorePath & path)
} }
} }
void DerivationBuilder::chownToBuilder(const Path & path) void DerivationBuilderImpl::chownToBuilder(const Path & path)
{ {
if (!buildUser) return; if (!buildUser) return;
if (chown(path.c_str(), buildUser->getUID(), buildUser->getGID()) == -1) if (chown(path.c_str(), buildUser->getUID(), buildUser->getGID()) == -1)
@ -2142,7 +1810,7 @@ void setupSeccomp()
} }
void DerivationBuilder::runChild() void DerivationBuilderImpl::runChild()
{ {
/* Warning: in the child we should absolutely not make any SQLite /* Warning: in the child we should absolutely not make any SQLite
calls! */ calls! */
@ -2655,7 +2323,7 @@ void DerivationBuilder::runChild()
} }
SingleDrvOutputs DerivationBuilder::registerOutputs() SingleDrvOutputs DerivationBuilderImpl::registerOutputs()
{ {
std::map<std::string, ValidPathInfo> infos; std::map<std::string, ValidPathInfo> infos;
@ -3207,7 +2875,7 @@ SingleDrvOutputs DerivationBuilder::registerOutputs()
} }
void DerivationBuilder::checkOutputs(const std::map<std::string, ValidPathInfo> & outputs) void DerivationBuilderImpl::checkOutputs(const std::map<std::string, ValidPathInfo> & outputs)
{ {
std::map<Path, const ValidPathInfo &> outputsByPath; std::map<Path, const ValidPathInfo &> outputsByPath;
for (auto & output : outputs) for (auto & output : outputs)
@ -3342,7 +3010,7 @@ void DerivationBuilder::checkOutputs(const std::map<std::string, ValidPathInfo>
} }
void DerivationBuilder::deleteTmpDir(bool force) void DerivationBuilderImpl::deleteTmpDir(bool force)
{ {
if (topTmpDir != "") { if (topTmpDir != "") {
/* Don't keep temporary directories for builtins because they /* Don't keep temporary directories for builtins because they
@ -3360,14 +3028,7 @@ void DerivationBuilder::deleteTmpDir(bool force)
} }
bool LocalDerivationGoal::isReadDesc(int fd) StorePath DerivationBuilderImpl::makeFallbackPath(OutputNameView outputName)
{
return (hook && DerivationGoal::isReadDesc(fd)) ||
(!hook && fd == builder.builderOut.get());
}
StorePath DerivationBuilder::makeFallbackPath(OutputNameView outputName)
{ {
// This is a bogus path type, constructed this way to ensure that it doesn't collide with any other store path // This is a bogus path type, constructed this way to ensure that it doesn't collide with any other store path
// See doc/manual/source/protocols/store-path.md for details // See doc/manual/source/protocols/store-path.md for details
@ -3380,7 +3041,7 @@ StorePath DerivationBuilder::makeFallbackPath(OutputNameView outputName)
} }
StorePath DerivationBuilder::makeFallbackPath(const StorePath & path) StorePath DerivationBuilderImpl::makeFallbackPath(const StorePath & path)
{ {
// This is a bogus path type, constructed this way to ensure that it doesn't collide with any other store path // This is a bogus path type, constructed this way to ensure that it doesn't collide with any other store path
// See doc/manual/source/protocols/store-path.md for details // See doc/manual/source/protocols/store-path.md for details

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@ include_dirs += include_directories('../..')
headers += files( headers += files(
'build/child.hh', 'build/child.hh',
'build/derivation-builder.hh',
'build/hook-instance.hh', 'build/hook-instance.hh',
'build/local-derivation-goal.hh', 'build/local-derivation-goal.hh',
'user-lock.hh', 'user-lock.hh',

View file

@ -1,5 +1,6 @@
sources += files( sources += files(
'build/child.cc', 'build/child.cc',
'build/derivation-builder.cc',
'build/hook-instance.cc', 'build/hook-instance.cc',
'build/local-derivation-goal.cc', 'build/local-derivation-goal.cc',
'pathlocks.cc', 'pathlocks.cc',