Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/libstore-tests/derivation-advanced-attrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes_defaults)

EXPECT_EQ(options, advancedAttributes_defaults);

EXPECT_EQ(options.canBuildLocally(*this->store, got), false);
EXPECT_EQ(options.willBuildLocally(*this->store, got), false);
EXPECT_EQ(options.substitutesAllowed(settings.getWorkerSettings()), true);
EXPECT_EQ(options.useUidRange(got), false);
});
Expand Down Expand Up @@ -335,8 +333,6 @@ TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes_structuredAttrs_d

EXPECT_EQ(options, advancedAttributes_structuredAttrs_defaults);

EXPECT_EQ(options.canBuildLocally(*this->store, got), false);
EXPECT_EQ(options.willBuildLocally(*this->store, got), false);
EXPECT_EQ(options.substitutesAllowed(settings.getWorkerSettings()), true);
EXPECT_EQ(options.useUidRange(got), false);
});
Expand Down Expand Up @@ -402,8 +398,6 @@ TYPED_TEST(DerivationAdvancedAttrsBothTest, advancedAttributes_structuredAttrs)

EXPECT_EQ(options, expected);

EXPECT_EQ(options.canBuildLocally(*this->store, got), false);
EXPECT_EQ(options.willBuildLocally(*this->store, got), false);
EXPECT_EQ(options.substitutesAllowed(settings.getWorkerSettings()), false);
EXPECT_EQ(options.useUidRange(got), true);
});
Expand Down
19 changes: 17 additions & 2 deletions src/libstore/build/derivation-building-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,25 @@ Goal::Co DerivationBuildingGoal::tryToBuild(StorePathSet inputPaths)
}
}

bool canBuildLocally = [&] {
if (drv->platform != settings.thisSystem.get() && !settings.extraPlatforms.get().count(drv->platform)
&& !drv->isBuiltin())
return false;

if (worker.settings.maxBuildJobs.get() == 0 && !drv->isBuiltin())
return false;

for (auto & feature : drvOptions.getRequiredSystemFeatures(*drv))
if (!worker.store.config.systemFeatures.get().count(feature))
return false;

return true;
}();

/* Don't do a remote build if the derivation has the attribute
`preferLocalBuild' set. Also, check and repair modes are only
supported for local builds. */
bool buildLocally = (buildMode != bmNormal || drvOptions.willBuildLocally(worker.store, *drv))
bool buildLocally = (buildMode != bmNormal || (drvOptions.preferLocalBuild && canBuildLocally))
&& worker.settings.maxBuildJobs.get() != 0;

if (buildLocally) {
Expand Down Expand Up @@ -363,7 +378,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild(StorePathSet inputPaths)

externalBuilder = settings.findExternalDerivationBuilderIfSupported(*drv);

if (!externalBuilder && !drvOptions.canBuildLocally(worker.store, *drv)) {
if (!externalBuilder && !canBuildLocally) {
auto msg =
fmt("Cannot build '%s'.\n"
"Reason: " ANSI_RED "required system or feature not available" ANSI_NORMAL
Expand Down
24 changes: 0 additions & 24 deletions src/libstore/derivation-options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "nix/store/store-api.hh"
#include "nix/util/types.hh"
#include "nix/util/util.hh"
#include "nix/store/globals.hh"
#include "nix/util/variant-wrapper.hh"

#include <optional>
Expand Down Expand Up @@ -359,29 +358,6 @@ StringSet DerivationOptions<Input>::getRequiredSystemFeatures(const BasicDerivat
return res;
}

template<typename Input>
bool DerivationOptions<Input>::canBuildLocally(Store & localStore, const BasicDerivation & drv) const
{
if (drv.platform != settings.thisSystem.get() && !settings.extraPlatforms.get().count(drv.platform)
&& !drv.isBuiltin())
return false;

if (settings.getWorkerSettings().maxBuildJobs.get() == 0 && !drv.isBuiltin())
return false;

for (auto & feature : getRequiredSystemFeatures(drv))
if (!localStore.config.systemFeatures.get().count(feature))
return false;

return true;
}

template<typename Input>
bool DerivationOptions<Input>::willBuildLocally(Store & localStore, const BasicDerivation & drv) const
{
return preferLocalBuild && canBuildLocally(localStore, drv);
}

template<typename Input>
bool DerivationOptions<Input>::substitutesAllowed(const WorkerSettings & workerSettings) const
{
Expand Down
11 changes: 0 additions & 11 deletions src/libstore/include/nix/store/derivation-options.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace nix {

class Store;
struct StoreDirConfig;
struct BasicDerivation;
struct StructuredAttrs;
Expand Down Expand Up @@ -184,16 +183,6 @@ struct DerivationOptions
*/
StringSet getRequiredSystemFeatures(const BasicDerivation & drv) const;

/**
* @param drv See note on `getRequiredSystemFeatures`
*/
bool canBuildLocally(Store & localStore, const BasicDerivation & drv) const;

/**
* @param drv See note on `getRequiredSystemFeatures`
*/
bool willBuildLocally(Store & localStore, const BasicDerivation & drv) const;

bool substitutesAllowed(const WorkerSettings & workerSettings) const;

/**
Expand Down
Loading