Skip to content

Commit 32d1904

Browse files
authored
Merge pull request #13268 from NixOS/derivation-builder-cleanup
Remove `buildUser` from `DerivationBuilder`
2 parents ed3e2a7 + 93ae95b commit 32d1904

File tree

3 files changed

+7
-38
lines changed

3 files changed

+7
-38
lines changed

src/libstore/build/derivation-building-goal.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,8 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
655655
builder->startBuilder();
656656

657657
} catch (BuildError & e) {
658+
builder.reset();
658659
outputLocks.unlock();
659-
builder->buildUser.reset();
660660
worker.permanentFailure = true;
661661
co_return done(BuildResult::InputRejected, {}, std::move(e));
662662
}

src/libstore/unix/build/derivation-builder.cc

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ class DerivationBuilderImpl : public DerivationBuilder, DerivationBuilderParams
106106

107107
private:
108108

109+
/**
110+
* User selected for running the builder.
111+
*/
112+
std::unique_ptr<UserLock> buildUser;
113+
109114
/**
110115
* The cgroup of the builder, if any.
111116
*/
@@ -251,30 +256,10 @@ class DerivationBuilderImpl : public DerivationBuilder, DerivationBuilderParams
251256

252257
public:
253258

254-
/**
255-
* Set up build environment / sandbox, acquiring resources (e.g.
256-
* locks as needed). After this is run, the builder should be
257-
* started.
258-
*
259-
* @returns true if successful, false if we could not acquire a build
260-
* user. In that case, the caller must wait and then try again.
261-
*/
262259
bool prepareBuild() override;
263260

264-
/**
265-
* Start building a derivation.
266-
*/
267-
void startBuilder() override;;
261+
void startBuilder() override;
268262

269-
/**
270-
* Tear down build environment after the builder exits (either on
271-
* its own or if it is killed).
272-
*
273-
* @returns The first case indicates failure during output
274-
* processing. A status code and exception are returned, providing
275-
* more information. The second case indicates success, and
276-
* realisations for each output of the derivation are returned.
277-
*/
278263
std::variant<std::pair<BuildResult::Status, Error>, SingleDrvOutputs> unprepareBuild() override;
279264

280265
private:
@@ -306,10 +291,6 @@ class DerivationBuilderImpl : public DerivationBuilder, DerivationBuilderParams
306291

307292
public:
308293

309-
/**
310-
* Stop the in-process nix daemon thread.
311-
* @see startDaemon
312-
*/
313294
void stopDaemon() override;
314295

315296
private:
@@ -341,15 +322,8 @@ class DerivationBuilderImpl : public DerivationBuilder, DerivationBuilderParams
341322

342323
public:
343324

344-
/**
345-
* Delete the temporary directory, if we have one.
346-
*/
347325
void deleteTmpDir(bool force) override;
348326

349-
/**
350-
* Kill any processes running under the build user UID or in the
351-
* cgroup of the build.
352-
*/
353327
void killSandbox(bool getStats) override;
354328

355329
private:

src/libstore/unix/include/nix/store/build/derivation-builder.hh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,6 @@ struct DerivationBuilderCallbacks
138138
*/
139139
struct DerivationBuilder : RestrictionContext
140140
{
141-
/**
142-
* User selected for running the builder.
143-
*/
144-
std::unique_ptr<UserLock> buildUser;
145-
146141
/**
147142
* The process ID of the builder.
148143
*/

0 commit comments

Comments
 (0)