diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index 281e1f6f0..38b219643 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -124,7 +124,7 @@ std::string removeWhitespace(std::string s) NixRepl::NixRepl(const LookupPath & lookupPath, nix::ref store, ref state, - std::function getValues, RunNix * runNix = nullptr) + std::function getValues, RunNix * runNix) : AbstractNixRepl(state) , debugTraceIndex(0) , getValues(getValues) @@ -839,9 +839,10 @@ std::unique_ptr AbstractNixRepl::create( { return std::make_unique( lookupPath, - openStore(), + std::move(store), state, - getValues + getValues, + runNix ); } @@ -859,7 +860,8 @@ ReplExitStatus AbstractNixRepl::runSimple( lookupPath, openStore(), evalState, - getValues + getValues, + /*runNix=*/nullptr ); repl->initEnv(); diff --git a/tests/functional/repl.sh b/tests/functional/repl.sh index 59d1f1be0..5d99fbb02 100755 --- a/tests/functional/repl.sh +++ b/tests/functional/repl.sh @@ -56,6 +56,10 @@ testRepl () { nix repl "${nixArgs[@]}" 2>&1 <<< "builtins.currentSystem" \ | grep "$(nix-instantiate --eval -E 'builtins.currentSystem')" + # regression test for #12163 + replOutput=$(nix repl "${nixArgs[@]}" 2>&1 <<< ":sh import $testDir/simple.nix") + echo "$replOutput" | grepInverse "error: Cannot run 'nix-shell'" + expectStderr 1 nix repl "${testDir}/simple.nix" \ | grepQuiet -s "error: path '$testDir/simple.nix' is not a flake" }