diff --git a/lix/libexpr/primops.cc b/lix/libexpr/primops.cc index e816e4025..e0c4dcef8 100644 --- a/lix/libexpr/primops.cc +++ b/lix/libexpr/primops.cc @@ -1023,7 +1023,7 @@ drvName, Bindings * attrs, Value & v) for (auto & i : outputs) { drv.env[i] = ""; drv.outputs.insert_or_assign(i, - DerivationOutput::Deferred { }); + DerivationOutput::InputAddressed { .path = StorePath::dummy }); } auto hashModulo = diff --git a/lix/libstore/build/derivation-goal.cc b/lix/libstore/build/derivation-goal.cc index 850fe33d4..337dd9f4a 100644 --- a/lix/libstore/build/derivation-goal.cc +++ b/lix/libstore/build/derivation-goal.cc @@ -526,21 +526,6 @@ try { if (useDerivation) { auto & fullDrv = *dynamic_cast(drv.get()); - auto drvType = fullDrv.type(); - bool resolveDrv = std::visit(overloaded { - [&](const DerivationType::InputAddressed & ia) { - /* must resolve if deferred. */ - return ia.deferred; - }, - [&](const DerivationType::ContentAddressed & ca) { - return false; - }, - }, drvType.raw); - - if (resolveDrv && !fullDrv.inputDrvs.empty()) { - throw UnimplementedError("ca derivations are not supported"); - } - // NOLINTNEXTLINE(cppcoreguidelines-avoid-capturing-lambda-coroutines) auto accumInputPaths = [&](const StorePath & depDrvPath, const StringSet & inputNode) -> kj::Promise> { try { diff --git a/lix/libstore/build/local-derivation-goal.cc b/lix/libstore/build/local-derivation-goal.cc index 232411fc0..52571802e 100644 --- a/lix/libstore/build/local-derivation-goal.cc +++ b/lix/libstore/build/local-derivation-goal.cc @@ -1878,12 +1878,6 @@ try { return newInfo0; }, - - [&](const DerivationOutput::Deferred &) -> ValidPathInfo { - // No derivation should reach that point without having been - // rewritten first - assert(false); - }, }, output->raw); /* FIXME: set proper permissions in restorePath() so diff --git a/lix/libstore/derivations.cc b/lix/libstore/derivations.cc index d84fd8d73..e1c0d3c7e 100644 --- a/lix/libstore/derivations.cc +++ b/lix/libstore/derivations.cc @@ -25,9 +25,6 @@ std::optional DerivationOutput::path(const Store & store, std::string dof.path(store, drvName, outputName) }; }, - [](const DerivationOutput::Deferred &) -> std::optional { - return std::nullopt; - }, }, raw); } @@ -72,7 +69,7 @@ bool DerivationType::hasKnownOutputPaths() const { return std::visit(overloaded { [](const InputAddressed & ia) { - return !ia.deferred; + return true; }, [](const ContentAddressed & ca) { return true; @@ -257,7 +254,7 @@ static DerivationOutput parseDerivationOutput( } } else { if (pathS == "") { - return DerivationOutput::Deferred { }; + throw UnimplementedError("deferred input-addressed derivations are not supported"); } validatePath(pathS); return DerivationOutput::InputAddressed { @@ -441,11 +438,6 @@ std::string Derivation::unparse(const Store & store, bool maskOutputs, s += ','; printUnquotedString(s, dof.ca.printMethodAlgo()); s += ','; printUnquotedString(s, dof.ca.hash.to_string(Base::Base16, false)); }, - [&](const DerivationOutput::Deferred &) { - s += ','; printUnquotedString(s, ""); - s += ','; printUnquotedString(s, ""); - s += ','; printUnquotedString(s, ""); - }, }, i.second.raw); s += ')'; } @@ -512,8 +504,7 @@ DerivationType BasicDerivation::type() const { std::set inputAddressedOutputs, - fixedCAOutputs, - deferredIAOutputs; + fixedCAOutputs; for (auto & i : outputs) { std::visit(overloaded { @@ -523,27 +514,19 @@ DerivationType BasicDerivation::type() const [&](const DerivationOutput::CAFixed &) { fixedCAOutputs.insert(i.first); }, - [&](const DerivationOutput::Deferred &) { - deferredIAOutputs.insert(i.first); - }, }, i.second.raw); } if (inputAddressedOutputs.empty() - && fixedCAOutputs.empty() - && deferredIAOutputs.empty()) + && fixedCAOutputs.empty()) throw Error("must have at least one output"); if (!inputAddressedOutputs.empty() - && fixedCAOutputs.empty() - && deferredIAOutputs.empty()) - return DerivationType::InputAddressed { - .deferred = false, - }; + && fixedCAOutputs.empty()) + return DerivationType::InputAddressed {}; if (inputAddressedOutputs.empty() - && !fixedCAOutputs.empty() - && deferredIAOutputs.empty()) + && !fixedCAOutputs.empty()) { if (fixedCAOutputs.size() > 1) // FIXME: Experimental feature? @@ -553,13 +536,6 @@ DerivationType BasicDerivation::type() const return DerivationType::ContentAddressed {}; } - if (inputAddressedOutputs.empty() - && fixedCAOutputs.empty() - && !deferredIAOutputs.empty()) - return DerivationType::InputAddressed { - .deferred = true, - }; - throw Error("can't mix derivation output types"); } @@ -748,11 +724,6 @@ void writeDerivation(Sink & out, const Store & store, const BasicDerivation & dr << dof.ca.printMethodAlgo() << dof.ca.hash.to_string(Base::Base16, false); }, - [&](const DerivationOutput::Deferred &) { - out << "" - << "" - << ""; - }, }, i.second.raw); } out << CommonProto::write(store, @@ -796,21 +767,7 @@ try { } drv.env = newEnv; - auto hashModulo = TRY_AWAIT(hashDerivationModulo(store, Derivation(drv), true)); - for (auto & [outputName, output] : drv.outputs) { - if (std::holds_alternative(output.raw)) { - auto h = get(hashModulo.hashes, outputName); - if (!h) - throw Error("derivation '%s' output '%s' has no hash (derivations.cc/rewriteDerivation)", - drv.name, outputName); - auto outPath = store.makeOutputPath(outputName, *h, drv.name); - drv.env[outputName] = store.printStorePath(outPath); - output = DerivationOutput::InputAddressed { - .path = std::move(outPath), - }; - } - } - + TRY_AWAIT(hashDerivationModulo(store, Derivation(drv), true)); co_return result::success(); } catch (...) { co_return result::current_exception(); @@ -950,10 +907,6 @@ try { return {result::current_exception()}; } }, - [](const DerivationOutput::Deferred &) -> kj::Promise> { - /* Nothing to check */ - return {result::success()}; - }, }, i.second.raw)); } co_return result::success(); @@ -976,7 +929,6 @@ JSON DerivationOutput::toJSON( res["hash"] = dof.ca.hash.to_string(Base::Base16, false); // FIXME print refs? }, - [&](const DerivationOutput::Deferred &) {}, }, raw); return res; } @@ -1029,7 +981,7 @@ DerivationOutput DerivationOutput::fromJSON( } else if (keys == (std::set { })) { - return DerivationOutput::Deferred {}; + throw UnimplementedError("deferred input-addressed derivations are not supported"); } else if (keys == (std::set { "hashAlgo", "impure" })) { diff --git a/lix/libstore/derivations.hh b/lix/libstore/derivations.hh index 6ecfc49ea..bd44e41b8 100644 --- a/lix/libstore/derivations.hh +++ b/lix/libstore/derivations.hh @@ -63,18 +63,9 @@ struct DerivationOutput GENERATE_CMP(CAFixed, me->ca); }; - /** - * Input-addressed output which depends on a (CA) derivation whose hash - * isn't known yet. - */ - struct Deferred { - GENERATE_CMP(Deferred); - }; - typedef std::variant< InputAddressed, - CAFixed, - Deferred + CAFixed > Raw; Raw raw; @@ -133,14 +124,7 @@ struct DerivationType { * Input-addressed derivation types */ struct InputAddressed { - /** - * True iff the derivation type can't be determined statically, - * for instance because it (transitively) depends on a content-addressed - * derivation. - */ - bool deferred; - - GENERATE_CMP(InputAddressed, me->deferred); + GENERATE_CMP(InputAddressed); }; /** diff --git a/lix/nix/develop.cc b/lix/nix/develop.cc index 90a14ba47..59acd316f 100644 --- a/lix/nix/develop.cc +++ b/lix/nix/develop.cc @@ -236,7 +236,7 @@ try { drv.env.emplace("name", drv.name); drv.inputSrcs.insert(std::move(getEnvShPath)); for (auto & output : drv.outputs) { - output.second = DerivationOutput::Deferred { }; + output.second = DerivationOutput::InputAddressed { .path = StorePath::dummy }; drv.env[output.first] = ""; } auto hashesModulo = TRY_AWAIT(hashDerivationModulo(*evalStore, drv, true)); diff --git a/tests/unit/libstore/data/libstore/derivation/output-deferred.json b/tests/unit/libstore/data/libstore/derivation/output-deferred.json deleted file mode 100644 index 0967ef424..000000000 --- a/tests/unit/libstore/data/libstore/derivation/output-deferred.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/tests/unit/libstore/derivation.cc b/tests/unit/libstore/derivation.cc index 21788ecf9..ec88d4678 100644 --- a/tests/unit/libstore/derivation.cc +++ b/tests/unit/libstore/derivation.cc @@ -102,10 +102,6 @@ TEST_JSON(DerivationTest, caFixedNAR, }), "drv-name", "output-name") -TEST_JSON(DerivationTest, deferred, - DerivationOutput::Deferred { }, - "drv-name", "output-name") - #undef TEST_JSON #define TEST_JSON(FIXTURE, NAME, VAL) \