Unify environment configuration and don't run in child shells

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.
This commit is contained in:
Andrew Childs 2018-10-25 00:30:34 +09:00
parent e6a698a701
commit 676ef10377
13 changed files with 56 additions and 51 deletions

View file

@ -61,8 +61,9 @@ in
# Don't execute this file when running in a pure nix-shell.
if test -n "$IN_NIX_SHELL"; then return; fi
export PATH=${config.environment.systemPath}
${config.system.build.setEnvironment.text}
if [ -z "$__NIX_DARWIN_SET_ENVIRONMENT_DONE" ]; then
. ${config.system.build.setEnvironment}
fi
# Return early if not running interactively, but after basic nix setup.
[[ $- != *i* ]] && return