nix-shell: Overwrite environment variables

Need to remember that std::map::insert() and emplace() don't overwrite
existing entries...

This fixes a regression relative to 1.11 that in particular triggers
in nested nix-shells.

Before:

  $ nativeBuildInputs=/foo nix-shell -p hello --run 'hello'
  build input /foo does not exist

After:

  $ nativeBuildInputs=/foo nix-shell -p hello --run 'hello'
  Hello, world!
This commit is contained in:
Eelco Dolstra 2017-02-24 13:31:46 +01:00
parent f023f64f40
commit 668fef2e4f
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -408,7 +408,7 @@ int main(int argc, char ** argv)
env["NIX_STORE"] = store->storeDir; env["NIX_STORE"] = store->storeDir;
for (auto & var : drv.env) for (auto & var : drv.env)
env.emplace(var); env[var.first] = var.second;
restoreAffinity(); restoreAffinity();