Skip to content

Commit

Permalink
Simplify the setting of the kind in hashDerivationModulo
Browse files Browse the repository at this point in the history
Co-authored-by: John Ericson <John.Ericson@Obsidian.Systems>
  • Loading branch information
thufschmitt and Ericson2314 committed Mar 18, 2022
1 parent fe8074a commit 8aab23c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/libstore/derivations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ static const DrvHashModulo pathDerivationModulo(Store & store, const StorePath &
*/
DrvHashModulo hashDerivationModulo(Store & store, const Derivation & drv, bool maskOutputs)
{
auto kind = DrvHashModulo::Kind::Regular;
/* Return a fixed hash for fixed-output derivations. */
if(drv.type() == DerivationType::CAFixed) {
std::map<std::string, Hash> outputHashes;
Expand All @@ -524,14 +523,19 @@ DrvHashModulo hashDerivationModulo(Store & store, const Derivation & drv, bool m
}
return DrvHashModulo{
.hashes = outputHashes,
.kind = kind,
.kind = DrvHashModulo::Kind::Regular,
};
} else if (drv.type() == DerivationType::CAFloating) {
kind = DrvHashModulo::Kind::Deferred;
}

/* For other derivations, replace the inputs paths with recursive
calls to this function. */

auto kind = drv.type() == DerivationType::CAFloating
? DrvHashModulo::Kind::Deferred
// Might be changed to `Deferred` below if we realise that one of the
// inputs has a Deferred hash
: DrvHashModulo::Kind::Regular;

std::map<std::string, StringSet> inputs2;
for (auto & [drvPath, inputOutputs0] : drv.inputDrvs) {
// Avoid lambda capture restriction with standard / Clang
Expand Down

0 comments on commit 8aab23c

Please sign in to comment.