aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Bereknyei <tomberek@gmail.com>2022-05-19 01:01:45 -0400
committerTom Bereknyei <tomberek@gmail.com>2022-05-19 01:02:24 -0400
commitf21dec5befc9ee273a5210dec322d30c3c3be595 (patch)
tree98d66e212af7439c0f04fa028a370f535e96294e
parente1f308a1ec3c395cd4978b45400f7a45adcea0dc (diff)
repl: hide flake behavior behind flag and provide warning
-rw-r--r--src/nix/repl.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index d4079816f..18cdb3580 100644
--- a/src/nix/repl.cc
+++ b/src/nix/repl.cc
@@ -897,17 +897,14 @@ struct CmdRepl : InstallablesCommand
}
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");
- if (this->_installables.size() > 1) {
+ 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();
+ auto filePath = this->_installables[0].data();
+ file = std::optional(filePath);
+ _installables.front() = _installables.back();
+ _installables.pop_back();
}
installables = InstallablesCommand::load();
}
@@ -940,9 +937,20 @@ struct CmdRepl : InstallablesCommand
auto installables = load();
NixRepl::AnnotatedValues values;
for (auto & installable: installables){
- auto [val, pos] = installable->toValue(*state);
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;
};