repl: hide flake behavior behind flag and provide warning

This commit is contained in:
Tom Bereknyei 2022-05-19 01:01:45 -04:00
parent e1f308a1ec
commit f21dec5bef

View file

@ -897,17 +897,14 @@ struct CmdRepl : InstallablesCommand
} }
void prepare() void prepare()
{ {
if (!settings.isExperimentalFeatureEnabled(Xp::Flakes) && !(file)) { if (!settings.isExperimentalFeatureEnabled(Xp::Flakes) && !(file) && this->_installables.size() >= 1) {
warn("future versions of Nix will require using `--file` to load a file"); warn("future versions of Nix will require using `--file` to load a file");
if (this->_installables.size() > 1) { if (this->_installables.size() > 1)
warn("more than one input file is not currently supported"); warn("more than one input file is not currently supported");
} auto filePath = this->_installables[0].data();
if (this->_installables.size() >= 1) { file = std::optional(filePath);
file = std::optional( _installables.front() = _installables.back();
this->_installables[0].data() _installables.pop_back();
);
}
_installables.clear();
} }
installables = InstallablesCommand::load(); installables = InstallablesCommand::load();
} }
@ -940,10 +937,21 @@ struct CmdRepl : InstallablesCommand
auto installables = load(); auto installables = load();
NixRepl::AnnotatedValues values; NixRepl::AnnotatedValues values;
for (auto & installable: installables){ for (auto & installable: installables){
auto what = installable->what();
if (!settings.isExperimentalFeatureEnabled(Xp::Flakes) && file){
auto [val, pos] = installable->toValue(*state); auto [val, pos] = installable->toValue(*state);
auto what = installable->what(); auto what = installable->what();
state->forceValue(*val, pos);
auto autoArgs = getAutoArgs(*state);
Value *valPost = state->allocValue();
state->autoCallFunction(*autoArgs, *val, *valPost);
state->forceValue(*valPost, pos);
values.push_back( {valPost, what });
} else {
auto [val, pos] = installable->toValue(*state);
values.push_back( {val,what} ); values.push_back( {val,what} );
} }
}
return values; return values;
}; };
auto repl = std::make_unique<NixRepl>( auto repl = std::make_unique<NixRepl>(