Make Machine::systemTypes a set not vector

This is more conceptually correct (the order does not matter), and also
matches what Hydra already does.

(Nix and Hydra matching is needed for dedup
https://github.com/NixOS/hydra/issues/1164)
This commit is contained in:
John Ericson 2024-01-23 12:30:26 -05:00
parent b6aee9a93f
commit 739032762a
3 changed files with 4 additions and 6 deletions

View file

@ -139,9 +139,7 @@ static int main_build_remote(int argc, char * * argv)
if (m.enabled if (m.enabled
&& (neededSystem == "builtin" && (neededSystem == "builtin"
|| std::find(m.systemTypes.begin(), || m.systemTypes.count(neededSystem) > 0) &&
m.systemTypes.end(),
neededSystem) != m.systemTypes.end()) &&
m.allSupported(requiredFeatures) && m.allSupported(requiredFeatures) &&
m.mandatoryMet(requiredFeatures)) m.mandatoryMet(requiredFeatures))
{ {
@ -214,7 +212,7 @@ static int main_build_remote(int argc, char * * argv)
for (auto & m : machines) for (auto & m : machines)
error error
% concatStringsSep<std::vector<std::string>>(", ", m.systemTypes) % concatStringsSep<StringSet>(", ", m.systemTypes)
% m.maxJobs % m.maxJobs
% concatStringsSep<StringSet>(", ", m.supportedFeatures) % concatStringsSep<StringSet>(", ", m.supportedFeatures)
% concatStringsSep<StringSet>(", ", m.mandatoryFeatures); % concatStringsSep<StringSet>(", ", m.mandatoryFeatures);

View file

@ -145,7 +145,7 @@ static Machine parseBuilderLine(const std::string & line)
return { return {
tokens[0], tokens[0],
isSet(1) ? tokenizeString<std::vector<std::string>>(tokens[1], ",") : std::vector<std::string>{settings.thisSystem}, isSet(1) ? tokenizeString<std::set<std::string>>(tokens[1], ",") : std::set<std::string>{settings.thisSystem},
isSet(2) ? tokens[2] : "", isSet(2) ? tokens[2] : "",
isSet(3) ? parseUnsignedIntField(3) : 1U, isSet(3) ? parseUnsignedIntField(3) : 1U,
isSet(4) ? parseUnsignedIntField(4) : 1U, isSet(4) ? parseUnsignedIntField(4) : 1U,

View file

@ -10,7 +10,7 @@ class Store;
struct Machine { struct Machine {
const std::string storeUri; const std::string storeUri;
const std::vector<std::string> systemTypes; const std::set<std::string> systemTypes;
const std::string sshKey; const std::string sshKey;
const unsigned int maxJobs; const unsigned int maxJobs;
const unsigned int speedFactor; const unsigned int speedFactor;