diff options
author | Tom Bereknyei <tomberek@gmail.com> | 2022-05-18 22:28:15 -0400 |
---|---|---|
committer | Tom Bereknyei <tomberek@gmail.com> | 2022-05-18 22:28:15 -0400 |
commit | e1f308a1ec3c395cd4978b45400f7a45adcea0dc (patch) | |
tree | 58d6ace63855fdf49302c1a6d3139f0a9ae168a6 | |
parent | 7534798eedb696226101f2c8793ba9ace049f5e4 (diff) |
repl: provide backward compat with legacy usage
-rw-r--r-- | src/libcmd/command.hh | 2 | ||||
-rw-r--r-- | src/nix/repl.cc | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/libcmd/command.hh b/src/libcmd/command.hh index 65eb0c4a0..2c88e1526 100644 --- a/src/libcmd/command.hh +++ b/src/libcmd/command.hh @@ -120,7 +120,7 @@ struct InstallablesCommand : virtual Args, SourceExprCommand std::optional<FlakeRef> getFlakeRefForCompletion() override; -private: +protected: std::vector<std::string> _installables; }; diff --git a/src/nix/repl.cc b/src/nix/repl.cc index cae76bb5d..d4079816f 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -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 { |