libstore: only check cgroup support when actually building
not all operations that involve workers need to build. for example nix copy --from calls instantiate thir worker with the *origin* store, not the store they copy *into*. for binary cache stores this is not likely to ever work if cgroups are enabled and the copy is run on normal user credentials, even though no cgroups will ever be needed to copy things fixes #1088 Change-Id: I065e29e1a1d0f58d81823609ef0701ff82cdd1d5
This commit is contained in:
@@ -225,6 +225,10 @@ retry:
|
||||
|
||||
assert(derivationType);
|
||||
|
||||
// check that all prerequisites for building locally are met (e.g. builds on linux
|
||||
// when cgroups are configured requires the system to be set up in a certain way).
|
||||
worker.requireBuildSupport();
|
||||
|
||||
/* Are we doing a chroot build? */
|
||||
{
|
||||
auto noChroot = parsedDrv->getBoolAttr("__noChroot");
|
||||
|
||||
@@ -40,6 +40,18 @@ Worker::Worker(Store & store, Store & evalStore, AvailableNamespaces namespaces)
|
||||
, namespaces(namespaces)
|
||||
{
|
||||
/* Debugging: prevent recursive workers. */
|
||||
}
|
||||
|
||||
void Worker::requireBuildSupport()
|
||||
{
|
||||
if (buildSupportEnsured) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!useBuildUsers()) {
|
||||
buildSupportEnsured = true;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
@@ -130,8 +142,9 @@ Worker::Worker(Store & store, Store & evalStore, AvailableNamespaces namespaces)
|
||||
}
|
||||
#undef CGROUPS_DISABLE_MSG
|
||||
#endif
|
||||
}
|
||||
|
||||
buildSupportEnsured = true;
|
||||
}
|
||||
|
||||
Worker::~Worker()
|
||||
{
|
||||
|
||||
@@ -120,6 +120,7 @@ public:
|
||||
private:
|
||||
|
||||
bool running = false;
|
||||
bool buildSupportEnsured = false;
|
||||
|
||||
template<typename G>
|
||||
struct CachedGoal
|
||||
@@ -236,6 +237,11 @@ public:
|
||||
|
||||
const AvailableNamespaces namespaces;
|
||||
|
||||
/**
|
||||
* Check that the current store can *build*, not only substitute.
|
||||
*/
|
||||
void requireBuildSupport();
|
||||
|
||||
private:
|
||||
Worker(Store & store, Store & evalStore, AvailableNamespaces namespaces);
|
||||
~Worker();
|
||||
|
||||
Reference in New Issue
Block a user