diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-10-12 23:51:23 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-10-13 02:15:48 +0000 |
commit | a4e5de1b9d26584615946057430df9e63d842f53 (patch) | |
tree | d671fa1b72a1c884869acadf2f397ce5cf495475 /src/libstore/misc.cc | |
parent | a0f369aa3fe9f2d223f45123db952ba7889c3c01 (diff) |
Derivations can output "text-hashed" data
In particular, this means that derivations can output derivations. But
that ramification isn't (yet!) useful as we would want, since there is
no way to have a dependent derivation that is itself a dependent
derivation.
Diffstat (limited to 'src/libstore/misc.cc')
-rw-r--r-- | src/libstore/misc.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc index 052936a8b..71fa81546 100644 --- a/src/libstore/misc.cc +++ b/src/libstore/misc.cc @@ -111,9 +111,21 @@ void Store::computeFSClosure(const StorePath & startPath, std::optional<ContentAddress> getDerivationCA(const BasicDerivation & drv) { auto out = drv.outputs.find("out"); - if (out != drv.outputs.end()) { - if (auto v = std::get_if<DerivationOutputCAFixed>(&out->second.output)) - return v->hash; + if (out == drv.outputs.end()) + return std::nullopt; + if (auto dof = std::get_if<DerivationOutputCAFixed>(&out->second.output)) { + return std::visit(overloaded { + [&](TextInfo ti) -> std::optional<ContentAddress> { + if (!ti.references.empty()) + return std::nullopt; + return static_cast<TextHash>(ti); + }, + [&](FixedOutputInfo fi) -> std::optional<ContentAddress> { + if (fi.references != PathReferences<StorePath> {}) + return std::nullopt; + return static_cast<FixedOutputHash>(fi); + }, + }, dof->ca); } return std::nullopt; } |