@@ -185,41 +185,44 @@ Goal::Co DerivationGoal::haveDerivation()
185185 if (!drv->type ().hasKnownOutputPaths ())
186186 experimentalFeatureSettings.require (Xp::CaDerivations);
187187
188- if (drv->type ().isImpure ()) {
189- experimentalFeatureSettings.require (Xp::ImpureDerivations);
190-
191- for (auto & [outputName, output] : drv->outputs ) {
192- auto randomPath = StorePath::random (outputPathName (drv->name , outputName));
193- assert (!worker.store .isValidPath (randomPath));
194- initialOutputs.insert ({
195- outputName,
196- InitialOutput {
197- .wanted = true ,
198- .outputHash = impureOutputHash,
199- .known = InitialOutputStatus {
200- .path = randomPath,
201- .status = PathStatus::Absent
202- }
203- }
204- });
205- }
206-
207- co_return gaveUpOnSubstitution ();
208- }
209-
210188 for (auto & i : drv->outputsAndOptPaths (worker.store ))
211189 if (i.second .second )
212190 worker.store .addTempRoot (*i.second .second );
213191
214- auto outputHashes = staticOutputHashes (worker.evalStore , *drv);
215- for (auto & [outputName, outputHash] : outputHashes)
216- initialOutputs.insert ({
217- outputName,
218- InitialOutput {
192+ {
193+ bool impure = drv->type ().isImpure ();
194+
195+ if (impure) experimentalFeatureSettings.require (Xp::ImpureDerivations);
196+
197+ auto outputHashes = staticOutputHashes (worker.evalStore , *drv);
198+ for (auto & [outputName, outputHash] : outputHashes) {
199+ InitialOutput v{
219200 .wanted = true , // Will be refined later
220201 .outputHash = outputHash
202+ };
203+
204+ /* TODO we might want to also allow randomizing the paths
205+ for regular CA derivations, e.g. for sake of checking
206+ determinism. */
207+ if (impure) {
208+ v.known = InitialOutputStatus {
209+ .path = StorePath::random (outputPathName (drv->name , outputName)),
210+ .status = PathStatus::Absent,
211+ };
221212 }
222- });
213+
214+ initialOutputs.insert ({
215+ outputName,
216+ std::move (v),
217+ });
218+ }
219+
220+ if (impure) {
221+ /* We don't yet have any safe way to cache an impure derivation at
222+ this step. */
223+ co_return gaveUpOnSubstitution ();
224+ }
225+ }
223226
224227 {
225228 /* Check what outputs paths are not already valid. */
0 commit comments