Skip to content

Commit

Permalink
Add rejectSystemFeatures to derivations
Browse files Browse the repository at this point in the history
  • Loading branch information
RossComputerGuy committed Feb 11, 2025
1 parent ad924a9 commit bcb4839
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/libstore/parsed-derivations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ StringSet ParsedDerivation::getRequiredSystemFeatures() const
return res;
}

StringSet ParsedDerivation::getRejectSystemFeatures() const
{
// FIXME: cache this?
StringSet res;
for (auto & i : getStringsAttr("rejectSystemFeatures").value_or(Strings()))
res.insert(i);
return res;
}

bool ParsedDerivation::canBuildLocally(Store & localStore) const
{
if (drv.platform != settings.thisSystem.get()
Expand All @@ -112,6 +121,9 @@ bool ParsedDerivation::canBuildLocally(Store & localStore) const
for (auto & feature : getRequiredSystemFeatures())
if (!localStore.systemFeatures.get().count(feature)) return false;

for (auto & feature : getRejectSystemFeatures())
if (localStore.systemFeatures.get().count(feature)) return false;

return true;
}

Expand Down
2 changes: 2 additions & 0 deletions src/libstore/parsed-derivations.hh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public:

StringSet getRequiredSystemFeatures() const;

StringSet getRejectSystemFeatures() const;

bool canBuildLocally(Store & localStore) const;

bool willBuildLocally(Store & localStore) const;
Expand Down
3 changes: 2 additions & 1 deletion src/libstore/unix/build/local-derivation-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,10 @@ void LocalDerivationGoal::startBuilder()

/* Right platform? */
if (!parsedDrv->canBuildLocally(worker.store))
throw Error("a '%s' with features {%s} is required to build '%s', but I am a '%s' with features {%s}",
throw Error("a '%s' with features {%s} & not {%s} is required to build '%s', but I am a '%s' with features {%s}",
drv->platform,
concatStringsSep(", ", parsedDrv->getRequiredSystemFeatures()),
concatStringsSep(", ", parsedDrv->getRejectSystemFeatures()),
worker.store.printStorePath(drvPath),
settings.thisSystem,
concatStringsSep<StringSet>(", ", worker.store.systemFeatures));
Expand Down

0 comments on commit bcb4839

Please sign in to comment.