Skip to content

Commit

Permalink
Get rid of impureOutputHash
Browse files Browse the repository at this point in the history
I do not believe there is any problem with computing
`hashDerivationModulo` the normal way with impure derivations.

Co-authored-by: Alain Zscheile <[email protected]>
  • Loading branch information
Ericson2314 and fogti committed Jan 16, 2023
1 parent 1df3d62 commit 76692cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 38 deletions.
32 changes: 9 additions & 23 deletions src/libstore/build/derivation-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,29 +201,6 @@ void DerivationGoal::haveDerivation()
if (!drv->type().hasKnownOutputPaths())
settings.requireExperimentalFeature(Xp::CaDerivations);

if (!drv->type().isPure()) {
settings.requireExperimentalFeature(Xp::ImpureDerivations);

for (auto & [outputName, output] : drv->outputs) {
auto randomPath = StorePath::random(outputPathName(drv->name, outputName));
assert(!worker.store.isValidPath(randomPath));
initialOutputs.insert({
outputName,
InitialOutput {
.wanted = true,
.outputHash = impureOutputHash,
.known = InitialOutputStatus {
.path = randomPath,
.status = PathStatus::Absent
}
}
});
}

gaveUpOnSubstitution();
return;
}

for (auto & i : drv->outputsAndOptPaths(worker.store))
if (i.second.second)
worker.store.addTempRoot(*i.second.second);
Expand All @@ -238,6 +215,15 @@ void DerivationGoal::haveDerivation()
}
});

if (!drv->type().isPure()) {
settings.requireExperimentalFeature(Xp::ImpureDerivations);

/* We don't yet have any safe way to cache an impure derivation at
this step. */
gaveUpOnSubstitution();
return;
}

/* Check what outputs paths are not already valid. */
auto [allValid, validOutputs] = checkPathValidity();

Expand Down
14 changes: 1 addition & 13 deletions src/libstore/derivations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -627,16 +627,6 @@ DrvHash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOut
};
}

if (!type.isPure()) {
std::map<std::string, Hash> outputHashes;
for (const auto & [outputName, _] : drv.outputs)
outputHashes.insert_or_assign(outputName, impureOutputHash);
return DrvHash {
.hashes = outputHashes,
.kind = DrvHash::Kind::Deferred,
};
}

auto kind = std::visit(overloaded {
[](const DerivationType::InputAddressed & ia) {
/* This might be a "pesimistically" deferred output, so we don't
Expand All @@ -649,7 +639,7 @@ DrvHash hashDerivationModulo(Store & store, const Derivation & drv, bool maskOut
: DrvHash::Kind::Deferred;
},
[](const DerivationType::Impure &) -> DrvHash::Kind {
assert(false);
return DrvHash::Kind::Deferred;
}
}, drv.type().raw());

Expand Down Expand Up @@ -888,6 +878,4 @@ std::optional<BasicDerivation> Derivation::tryResolve(
return resolved;
}

const Hash impureOutputHash = hashString(htSHA256, "impure");

}
2 changes: 0 additions & 2 deletions src/libstore/derivations.hh
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,4 @@ std::string hashPlaceholder(const std::string_view outputName);
dependency which is a CA derivation. */
std::string downstreamPlaceholder(const Store & store, const StorePath & drvPath, std::string_view outputName);

extern const Hash impureOutputHash;

}

0 comments on commit 76692cc

Please sign in to comment.