aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-10-01 18:05:53 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-11 21:20:37 +0000
commit0948b8e94dfbf87ed2a695c6c7d8dac250e2c293 (patch)
treef02b35f7801b5b6632269f8e7d5d7eaaee1cef63 /src/libexpr
parentaee56e0f895e7b9890d1ec948b24c75478f9e88e (diff)
Reduce variants for derivation hash modulo
This changes was taken from dynamic derivation (#4628). It` somewhat undoes the refactors I first did for floating CA derivations, as the benefit of hindsight + requirements of dynamic derivations made me reconsider some things. They aren't to consequential, but I figured they might be good to land first, before the more profound changes @thufschmitt has in the works.
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/primops.cc45
1 files changed, 25 insertions, 20 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 3124025aa..0980e75f4 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -1207,32 +1207,37 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
// hash per output.
auto hashModulo = hashDerivationModulo(*state.store, Derivation(drv), true);
std::visit(overloaded {
- [&](Hash & h) {
- for (auto & i : outputs) {
- auto outPath = state.store->makeOutputPath(i, h, drvName);
- drv.env[i] = state.store->printStorePath(outPath);
- drv.outputs.insert_or_assign(i,
- DerivationOutput {
- .output = DerivationOutputInputAddressed {
- .path = std::move(outPath),
- },
- });
+ [&](const DrvHash & drvHash) {
+ auto & h = drvHash.hash;
+ switch (drvHash.kind) {
+ case DrvHash::Kind::Deferred:
+ for (auto & i : outputs) {
+ drv.outputs.insert_or_assign(i,
+ DerivationOutput {
+ .output = DerivationOutputDeferred{},
+ });
+ }
+ break;
+ case DrvHash::Kind::Regular:
+ for (auto & i : outputs) {
+ auto outPath = state.store->makeOutputPath(i, h, drvName);
+ drv.env[i] = state.store->printStorePath(outPath);
+ drv.outputs.insert_or_assign(i,
+ DerivationOutput {
+ .output = DerivationOutputInputAddressed {
+ .path = std::move(outPath),
+ },
+ });
+ }
+ break;
}
},
- [&](CaOutputHashes &) {
+ [&](const CaOutputHashes &) {
// Shouldn't happen as the toplevel derivation is not CA.
assert(false);
},
- [&](DeferredHash &) {
- for (auto & i : outputs) {
- drv.outputs.insert_or_assign(i,
- DerivationOutput {
- .output = DerivationOutputDeferred{},
- });
- }
- },
},
- hashModulo);
+ hashModulo.raw());
}