Skip to content

Commit bcb4839

Browse files
Add rejectSystemFeatures to derivations
1 parent ad924a9 commit bcb4839

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/libstore/parsed-derivations.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ StringSet ParsedDerivation::getRequiredSystemFeatures() const
9898
return res;
9999
}
100100

101+
StringSet ParsedDerivation::getRejectSystemFeatures() const
102+
{
103+
// FIXME: cache this?
104+
StringSet res;
105+
for (auto & i : getStringsAttr("rejectSystemFeatures").value_or(Strings()))
106+
res.insert(i);
107+
return res;
108+
}
109+
101110
bool ParsedDerivation::canBuildLocally(Store & localStore) const
102111
{
103112
if (drv.platform != settings.thisSystem.get()
@@ -112,6 +121,9 @@ bool ParsedDerivation::canBuildLocally(Store & localStore) const
112121
for (auto & feature : getRequiredSystemFeatures())
113122
if (!localStore.systemFeatures.get().count(feature)) return false;
114123

124+
for (auto & feature : getRejectSystemFeatures())
125+
if (localStore.systemFeatures.get().count(feature)) return false;
126+
115127
return true;
116128
}
117129

src/libstore/parsed-derivations.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public:
3333

3434
StringSet getRequiredSystemFeatures() const;
3535

36+
StringSet getRejectSystemFeatures() const;
37+
3638
bool canBuildLocally(Store & localStore) const;
3739

3840
bool willBuildLocally(Store & localStore) const;

src/libstore/unix/build/local-derivation-goal.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,10 @@ void LocalDerivationGoal::startBuilder()
532532

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

0 commit comments

Comments
 (0)