1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-20 11:11:03 -04:00

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,9 +937,20 @@ struct CmdRepl : InstallablesCommand
auto installables = load(); auto installables = load();
NixRepl::AnnotatedValues values; NixRepl::AnnotatedValues values;
for (auto & installable: installables){ for (auto & installable: installables){
auto [val, pos] = installable->toValue(*state);
auto what = installable->what(); auto what = installable->what();
values.push_back( {val,what} ); if (!settings.isExperimentalFeatureEnabled(Xp::Flakes) && file){
auto [val, pos] = installable->toValue(*state);
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} );
}
} }
return values; return values;
}; };