repl: only send overridden settings to nix subprocesses

The nix-shell and nix-env subprocess spawned by :sh and :i respectively should
use the same settings as the nix repl they were launched from. Previously, this
was accomplished by sending them the entire configuration explicitly, causing
warnings like the following:

   warning: Ignoring setting 'auto-allocate-uids' because experimental feature 'auto-allocate-uids' is not enabled

In addition, if connected to the daemon, all other settings would be forwarded
to the daemon, further causing large quantities of warnings like the following
if the user is not trusted:

   warning: Ignoring the client-specified setting 'allow-symlinked-store', because it is a restricted setting and you are not a trusted user

Similarly to ece99fee23 (for the build hook) and
523965697d (for the post-build-hook), we will now
only send overridden settings to the subprocess. The resulting configuration is
the same, and all warnings are avoided because the client was already smart
enough to not send unchanged defaults to the daemon.

Fixes: https://git.lix.systems/lix-project/lix/issues/811

Change-Id: Icbe923cbe166aa3f462916f2b164285882564abd
This commit is contained in:
Alois Wohlschlager
2025-04-29 19:30:17 +02:00
parent 14055866dc
commit f7c5cf6c62
+1 -1
View File
@@ -243,7 +243,7 @@ NixRepl::NixRepl(const SearchPath & searchPath, nix::ref<Store> store, EvalState
void runNix(Path program, const Strings & args)
{
auto subprocessEnv = getEnv();
subprocessEnv["NIX_CONFIG"] = globalConfig.toKeyValue();
subprocessEnv["NIX_CONFIG"] = globalConfig.toKeyValue(true);
runProgram2(RunOptions {
.program = settings.nixBinDir+ "/" + program,