1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00

Merge pull request #13268 from NixOS/derivation-builder-cleanup

Remove `buildUser` from `DerivationBuilder`
This commit is contained in:
John Ericson 2025-05-26 12:10:57 -04:00 committed by GitHub
commit 32d19040e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 38 deletions

View file

@ -655,8 +655,8 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
builder->startBuilder(); builder->startBuilder();
} catch (BuildError & e) { } catch (BuildError & e) {
builder.reset();
outputLocks.unlock(); outputLocks.unlock();
builder->buildUser.reset();
worker.permanentFailure = true; worker.permanentFailure = true;
co_return done(BuildResult::InputRejected, {}, std::move(e)); co_return done(BuildResult::InputRejected, {}, std::move(e));
} }

View file

@ -106,6 +106,11 @@ public:
private: private:
/**
* User selected for running the builder.
*/
std::unique_ptr<UserLock> buildUser;
/** /**
* The cgroup of the builder, if any. * The cgroup of the builder, if any.
*/ */
@ -251,30 +256,10 @@ private:
public: public:
/**
* Set up build environment / sandbox, acquiring resources (e.g.
* locks as needed). After this is run, the builder should be
* started.
*
* @returns true if successful, false if we could not acquire a build
* user. In that case, the caller must wait and then try again.
*/
bool prepareBuild() override; bool prepareBuild() override;
/** void startBuilder() override;
* Start building a derivation.
*/
void startBuilder() override;;
/**
* Tear down build environment after the builder exits (either on
* its own or if it is killed).
*
* @returns The first case indicates failure during output
* processing. A status code and exception are returned, providing
* more information. The second case indicates success, and
* realisations for each output of the derivation are returned.
*/
std::variant<std::pair<BuildResult::Status, Error>, SingleDrvOutputs> unprepareBuild() override; std::variant<std::pair<BuildResult::Status, Error>, SingleDrvOutputs> unprepareBuild() override;
private: private:
@ -306,10 +291,6 @@ private:
public: public:
/**
* Stop the in-process nix daemon thread.
* @see startDaemon
*/
void stopDaemon() override; void stopDaemon() override;
private: private:
@ -341,15 +322,8 @@ private:
public: public:
/**
* Delete the temporary directory, if we have one.
*/
void deleteTmpDir(bool force) override; void deleteTmpDir(bool force) override;
/**
* Kill any processes running under the build user UID or in the
* cgroup of the build.
*/
void killSandbox(bool getStats) override; void killSandbox(bool getStats) override;
private: private:

View file

@ -138,11 +138,6 @@ struct DerivationBuilderCallbacks
*/ */
struct DerivationBuilder : RestrictionContext struct DerivationBuilder : RestrictionContext
{ {
/**
* User selected for running the builder.
*/
std::unique_ptr<UserLock> buildUser;
/** /**
* The process ID of the builder. * The process ID of the builder.
*/ */