diff options
author | Carlo Nucera <carlo.nucera@protonmail.com> | 2020-07-17 11:33:27 -0400 |
---|---|---|
committer | Carlo Nucera <carlo.nucera@protonmail.com> | 2020-07-17 12:05:54 -0400 |
commit | 1feb8981df6adf8519a1f2d31883eb12db11fcb5 (patch) | |
tree | c0530dc9a70dc3e2ce70c4f2b65ce0c2d64aaa3b /src/libstore | |
parent | 487c5751c64efa9d39c9e39d16eb1fee9fc0d941 (diff) |
Revert "Don't anticipate hash algo without hash in derivation for now"
This reverts commit 3804e3df9bb479fe1d399f29d16a1aabaf352c19.
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/derivations.cc | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index bff228230..487ed47e9 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -387,13 +387,34 @@ bool isDerivation(const string & fileName) DerivationType BasicDerivation::type() const { - if (outputs.size() == 1 && - outputs.begin()->first == "out" && - std::holds_alternative<DerivationOutputFixed>(outputs.begin()->second.output)) - { + std::set<std::string_view> inputAddressedOutputs, fixedCAOutputs; + for (auto & i : outputs) { + 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; } else { - return DerivationType::Regular; + throw Error("Can't mix derivation output types"); } } |