Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate using pam_env.so during install to set variables for all shells #7027

Open
Hoverbear opened this issue Sep 12, 2022 · 0 comments

Comments

@Hoverbear
Copy link
Contributor

Is your feature request related to a problem? Please describe.

It would be desirable for Nix to utilize /etc/environment on systems with pam_env.so to set variables across all shells. This would be beneficial as Nix could support theoretically any shell on those platforms.

Describe the solution you'd like

On systems where pam_env.so existed, the scripts/install-nix-from-closure.sh script could manipulate the /etc/environment file instead of the current process of scanning for relevant files for pre-defined shells:

added=
p=$HOME/.nix-profile/etc/profile.d/nix.sh
if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ]; then
# Make the shell source nix.sh during login.
for i in .bash_profile .bash_login .profile; do
fn="$HOME/$i"
if [ -w "$fn" ]; then
if ! grep -q "$p" "$fn"; then
echo "modifying $fn..." >&2
printf '\nif [ -e %s ]; then . %s; fi # added by Nix installer\n' "$p" "$p" >> "$fn"
fi
added=1
break
fi
done
for i in .zshenv .zshrc; do
fn="$HOME/$i"
if [ -w "$fn" ]; then
if ! grep -q "$p" "$fn"; then
echo "modifying $fn..." >&2
printf '\nif [ -e %s ]; then . %s; fi # added by Nix installer\n' "$p" "$p" >> "$fn"
fi
added=1
break
fi
done
fi

Describe alternatives you've considered

We could continue doing as we currently do and only set pre-known shells.

Additional context

Brought up by #7014 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants