cli: remove ca support from commands

this mostly takes the form of removes feature checks and the associated
"ca derivations enabled" branches, but for the realisation info command
turns into a stub. we keep it around for compatibility, but from now on
it will always throws "ca derivations not implemented" errors when run.

Change-Id: I0abea5f76262013415330adcca2b498c6dca555b
This commit is contained in:
eldritch horrors
2025-05-20 17:43:46 +00:00
parent 6567707dc1
commit a7866d56b8
5 changed files with 17 additions and 110 deletions
-6
View File
@@ -405,12 +405,6 @@ static void main_nix_build(AsyncIoRoot & aio, std::string programName, Strings a
shell = store->printStorePath(shellDrvOutputs.at("out").value()) + "/bin/bash";
}
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
auto resolvedDrv = aio.blockOn(drv.tryResolve(*store));
assert(resolvedDrv && "Successfully resolved the derivation");
drv = *resolvedDrv;
}
// Set the environment.
auto env = getEnv();
+1 -42
View File
@@ -11,46 +11,6 @@
namespace nix {
/**
* Return the rewrites that are needed to resolve a string whose context is
* included in `dependencies`.
*/
StringPairs resolveRewrites(
Store & store,
const std::vector<BuiltPathWithResult> & dependencies)
{
StringPairs res;
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
for (auto & dep : dependencies) {
if (auto drvDep = std::get_if<BuiltPathBuilt>(&dep.path)) {
for (auto & [ outputName, outputPath ] : drvDep->outputs) {
res.emplace(
DownstreamPlaceholder::fromSingleDerivedPathBuilt(
SingleDerivedPath::Built {
.drvPath = makeConstantStorePath(drvDep->drvPath.path),
.output = outputName,
}).render(),
store.printStorePath(outputPath)
);
}
}
}
}
return res;
}
/**
* Resolve the given string assuming the given context.
*/
std::string resolveString(
Store & store,
const std::string & toResolve,
const std::vector<BuiltPathWithResult> & dependencies)
{
auto rewrites = resolveRewrites(store, dependencies);
return rewriteStrings(toResolve, rewrites);
}
UnresolvedApp InstallableValue::toApp(EvalState & state)
{
auto cursor = getCursor(state);
@@ -136,8 +96,7 @@ App UnresolvedApp::resolve(EvalState & state, ref<Store> evalStore, ref<Store> s
installableContext.push_back(
make_ref<InstallableDerivedPath>(store, DerivedPath { ctxElt }));
auto builtContext = Installable::build(state, evalStore, store, Realise::Outputs, installableContext);
res.program = resolveString(*store, unresolved.program, builtContext);
Installable::build(state, evalStore, store, Realise::Outputs, installableContext);
if (!store->isInStore(res.program))
throw Error("app program '%s' is not in the Nix store", res.program);
+12 -19
View File
@@ -235,26 +235,19 @@ try {
drv.name += "-env";
drv.env.emplace("name", drv.name);
drv.inputSrcs.insert(std::move(getEnvShPath));
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
for (auto & output : drv.outputs) {
output.second = DerivationOutput::Deferred {},
drv.env[output.first] = hashPlaceholder(output.first);
}
} else {
for (auto & output : drv.outputs) {
output.second = DerivationOutput::Deferred { };
drv.env[output.first] = "";
}
auto hashesModulo = TRY_AWAIT(hashDerivationModulo(*evalStore, drv, true));
for (auto & output : drv.outputs) {
output.second = DerivationOutput::Deferred { };
drv.env[output.first] = "";
}
auto hashesModulo = TRY_AWAIT(hashDerivationModulo(*evalStore, drv, true));
for (auto & output : drv.outputs) {
Hash h = hashesModulo.hashes.at(output.first);
auto outPath = store->makeOutputPath(output.first, h, drv.name);
output.second = DerivationOutput::InputAddressed {
.path = outPath,
};
drv.env[output.first] = store->printStorePath(outPath);
}
for (auto & output : drv.outputs) {
Hash h = hashesModulo.hashes.at(output.first);
auto outPath = store->makeOutputPath(output.first, h, drv.name);
output.second = DerivationOutput::InputAddressed {
.path = outPath,
};
drv.env[output.first] = store->printStorePath(outPath);
}
auto shellDrvPath = TRY_AWAIT(writeDerivation(*evalStore, drv));
+1 -31
View File
@@ -45,37 +45,7 @@ struct CmdRealisationInfo : BuiltPathsCommand, MixJSON
void run(ref<Store> store, BuiltPaths && paths) override
{
experimentalFeatureSettings.require(Xp::CaDerivations);
RealisedPath::Set realisations;
for (auto & builtPath : paths) {
auto theseRealisations = aio().blockOn(builtPath.toRealisedPaths(*store));
realisations.insert(theseRealisations.begin(), theseRealisations.end());
}
if (json) {
JSON res = JSON::array();
for (auto & path : realisations) {
JSON currentPath;
if (auto realisation = std::get_if<Realisation>(&path.raw))
currentPath = realisation->toJSON();
else
currentPath["opaquePath"] = store->printStorePath(path.path());
res.push_back(currentPath);
}
logger->cout("%s", res);
}
else {
for (auto & path : realisations) {
if (auto realisation = std::get_if<Realisation>(&path.raw)) {
logger->cout("%s %s",
realisation->id.to_string(),
store->printStorePath(realisation->outPath));
} else
logger->cout("%s", store->printStorePath(path.path()));
}
}
throw UnimplementedError("CA derivations are no longer supported");
}
};
+3 -12
View File
@@ -50,19 +50,10 @@ Drv::Drv(std::string &attrPath, nix::EvalState &state, nix::DrvInfo &drvInfo,
auto localStore = state.ctx.store.try_cast_shared<nix::LocalFSStore>();
try {
// CA derivations do not have static output paths, so we have to
// defensively not query output paths in case we encounter one.
for (auto &[outputName, optOutputPath] :
drvInfo.queryOutputs(state, !nix::experimentalFeatureSettings.isEnabled(
nix::Xp::CaDerivations))) {
if (optOutputPath) {
outputs[outputName] =
localStore->printStorePath(*optOutputPath);
} else {
assert(nix::experimentalFeatureSettings.isEnabled(
nix::Xp::CaDerivations));
outputs[outputName] = std::nullopt;
}
drvInfo.queryOutputs(state, true)) {
assert(optOutputPath);
outputs[outputName] = localStore->printStorePath(*optOutputPath);
}
} catch (const std::exception &e) { // NOLINT(lix-foreign-exceptions)
state.ctx.errors.make<nix::EvalError>(