1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 06:01:48 +02:00

Simplify local drv goal a bit more

- `chrootParentDir` can be a local variable instead of a class variable.

- `getChildStatus` can be inlined. Again, we have the `assert(!hook);`
  in the local building case, which makes for a simpler thing inlined.
This commit is contained in:
Las 2025-03-10 22:31:13 +00:00 committed by John Ericson
parent 4b521f14ac
commit a87589a035
4 changed files with 8 additions and 30 deletions

View file

@ -801,16 +801,6 @@ void replaceValidPath(const Path & storePath, const Path & tmpPath)
} }
int DerivationGoal::getChildStatus()
{
#ifndef _WIN32 // TODO enable build hook on Windows
return hook->pid.kill();
#else
return 0;
#endif
}
void runPostBuildHook( void runPostBuildHook(
Store & store, Store & store,
Logger & logger, Logger & logger,
@ -908,7 +898,12 @@ Goal::Co DerivationGoal::hookDone()
to have terminated. In fact, the builder could also have to have terminated. In fact, the builder could also have
simply have closed its end of the pipe, so just to be sure, simply have closed its end of the pipe, so just to be sure,
kill it. */ kill it. */
int status = getChildStatus(); int status =
#ifndef _WIN32 // TODO enable build hook on Windows
hook->pid.kill();
#else
0;
#endif
debug("builder process for '%s' finished", worker.store.printStorePath(drvPath)); debug("builder process for '%s' finished", worker.store.printStorePath(drvPath));

View file

@ -262,8 +262,6 @@ struct DerivationGoal : public Goal
*/ */
HookReply tryBuildHook(); HookReply tryBuildHook();
virtual int getChildStatus();
/** /**
* Check that the derivation outputs all exist and register them * Check that the derivation outputs all exist and register them
* as valid. * as valid.

View file

@ -282,7 +282,7 @@ Goal::Co LocalDerivationGoal::tryLocalBuild()
to have terminated. In fact, the builder could also have to have terminated. In fact, the builder could also have
simply have closed its end of the pipe, so just to be sure, simply have closed its end of the pipe, so just to be sure,
kill it. */ kill it. */
int status = getChildStatus(); int status = pid.kill();
debug("builder process for '%s' finished", worker.store.printStorePath(drvPath)); debug("builder process for '%s' finished", worker.store.printStorePath(drvPath));
@ -412,12 +412,6 @@ 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);
int LocalDerivationGoal::getChildStatus()
{
return hook ? DerivationGoal::getChildStatus() : pid.kill();
}
bool LocalDerivationGoal::cleanupDecideWhetherDiskFull() bool LocalDerivationGoal::cleanupDecideWhetherDiskFull()
{ {
bool diskFull = false; bool diskFull = false;
@ -787,7 +781,7 @@ void LocalDerivationGoal::startBuilder()
environment using bind-mounts. We put it in the Nix store environment using bind-mounts. We put it in the Nix store
so that the build outputs can be moved efficiently from the so that the build outputs can be moved efficiently from the
chroot to their final location. */ chroot to their final location. */
chrootParentDir = worker.store.Store::toRealPath(drvPath) + ".chroot"; auto chrootParentDir = worker.store.Store::toRealPath(drvPath) + ".chroot";
deletePath(chrootParentDir); deletePath(chrootParentDir);
/* Clean up the chroot directory automatically. */ /* Clean up the chroot directory automatically. */

View file

@ -71,13 +71,6 @@ struct LocalDerivationGoal : public DerivationGoal
*/ */
bool useChroot = false; bool useChroot = false;
/**
* The parent directory of `chrootRootDir`. It has permission 700
* and is owned by root to ensure other users cannot mess with
* `chrootRootDir`.
*/
Path chrootParentDir;
/** /**
* The root of the chroot environment. * The root of the chroot environment.
*/ */
@ -237,8 +230,6 @@ struct LocalDerivationGoal : public DerivationGoal
*/ */
void chownToBuilder(const Path & path); void chownToBuilder(const Path & path);
int getChildStatus() override;
/** /**
* Run the builder's process. * Run the builder's process.
*/ */