Revert "Don't anticipate hash algo without hash in derivation for now"

This reverts commit 3804e3df9b.
This commit is contained in:
Carlo Nucera 2020-07-17 11:33:27 -04:00
parent 487c5751c6
commit 1feb8981df

View file

@ -387,13 +387,34 @@ bool isDerivation(const string & fileName)
DerivationType BasicDerivation::type() const DerivationType BasicDerivation::type() const
{ {
if (outputs.size() == 1 && std::set<std::string_view> inputAddressedOutputs, fixedCAOutputs;
outputs.begin()->first == "out" && for (auto & i : outputs) {
std::holds_alternative<DerivationOutputFixed>(outputs.begin()->second.output)) std::visit(overloaded {
{ [&](DerivationOutputInputAddressed _) {
inputAddressedOutputs.insert(i.first);
},
[&](DerivationOutputFixed _) {
fixedCAOutputs.insert(i.first);
},
[&](DerivationOutputFloating _) {
throw Error("Floating CA output derivations are not yet implemented");
},
}, i.second.output);
}
if (inputAddressedOutputs.empty() && fixedCAOutputs.empty()) {
throw Error("Must have at least one output");
} else if (! inputAddressedOutputs.empty() && fixedCAOutputs.empty()) {
return DerivationType::Regular;
} else if (inputAddressedOutputs.empty() && ! fixedCAOutputs.empty()) {
if (fixedCAOutputs.size() > 1)
// FIXME: Experimental feature?
throw Error("Only one fixed output is allowed for now");
if (*fixedCAOutputs.begin() != "out")
throw Error("Single fixed output must be named \"out\"");
return DerivationType::CAFixed; return DerivationType::CAFixed;
} else { } else {
return DerivationType::Regular; throw Error("Can't mix derivation output types");
} }
} }