1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 15:32:43 +01:00

Combine DerivationBuilder::{prepareBuild,startBuilder}

After many other cleanups, it turns out there is no reason for these to
be separate methods. We can combine them to simplify things.
This commit is contained in:
John Ericson 2025-09-03 17:58:50 -04:00
parent 14c206f05a
commit 2acb9559d5
3 changed files with 33 additions and 41 deletions

View file

@ -214,9 +214,7 @@ protected:
public:
bool prepareBuild() override;
Descriptor startBuilder() override;
std::optional<Descriptor> startBuild() override;
SingleDrvOutputs unprepareBuild() override;
@ -470,19 +468,6 @@ bool DerivationBuilderImpl::killChild()
return ret;
}
bool DerivationBuilderImpl::prepareBuild()
{
if (useBuildUsers()) {
if (!buildUser)
buildUser = getBuildUser();
if (!buildUser)
return false;
}
return true;
}
SingleDrvOutputs DerivationBuilderImpl::unprepareBuild()
{
/* Since we got an EOF on the logger pipe, the builder is presumed
@ -679,8 +664,16 @@ static bool checkNotWorldWritable(std::filesystem::path path)
return true;
}
Descriptor DerivationBuilderImpl::startBuilder()
std::optional<Descriptor> DerivationBuilderImpl::startBuild()
{
if (useBuildUsers()) {
if (!buildUser)
buildUser = getBuildUser();
if (!buildUser)
return std::nullopt;
}
/* Make sure that no other processes are executing under the
sandbox uids. This must be done before any chownToBuilder()
calls. */