repl: provide backward compat with legacy usage

This commit is contained in:
Tom Bereknyei 2022-05-18 22:28:15 -04:00
parent 7534798eed
commit e1f308a1ec
2 changed files with 17 additions and 1 deletions

View file

@ -120,7 +120,7 @@ struct InstallablesCommand : virtual Args, SourceExprCommand
std::optional<FlakeRef> getFlakeRefForCompletion() override;
private:
protected:
std::vector<std::string> _installables;
};

View file

@ -895,6 +895,22 @@ struct CmdRepl : InstallablesCommand
CmdRepl(){
evalSettings.pureEval = false;
}
void prepare()
{
if (!settings.isExperimentalFeatureEnabled(Xp::Flakes) && !(file)) {
warn("future versions of Nix will require using `--file` to load a file");
if (this->_installables.size() > 1) {
warn("more than one input file is not currently supported");
}
if (this->_installables.size() >= 1) {
file = std::optional(
this->_installables[0].data()
);
}
_installables.clear();
}
installables = InstallablesCommand::load();
}
std::vector<std::string> files;
Strings getDefaultFlakeAttrPaths() override
{