This should enable `nix run` to work under shells like fish and zsh, as well as making child shells not needlessly reset any environment that should be inherited. Implementation adapted from NixOS.