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

bugfix: add a fish shell file to correctly source vars (#3980) #3985

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions scripts/install-nix-from-closure.sh
Expand Up @@ -247,3 +247,42 @@ variables are set, either log in again, or type
in your shell.
EOF
fi

added=
p=$HOME/.nix-profile/etc/profile.d/nix.fish
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming nix-profile.fish.in is converted to nix.fish somehow, but that's unclear.

if [ -z "$NIX_INSTALLER_NO_MODIFY_PROFILE" ] && [ -f "$HOME/.config/fish/fish.config"]; then
# Make the fish shell source nix.fish during login.
for i in fish.config; do
fn="$HOME/.config/fish/$i"
if [ -w "$fn" ]; then
if ! grep -q "$p" "$fn"; then
echo "modifying $fn..." >&2
echo -e "\n[ -e $p ] && . $p # added by Nix installer" >> "$fn"
fi
added=1
break
fi
done
fi

if [ -z "$added" ]; then
cat >&2 <<EOF

Installation finished! To ensure that the necessary environment
variables are set, please add the line

. $p

to your shell configuration file (~/.config/fish/fish.config).
EOF
else
cat >&2 <<EOF

Installation finished! To ensure that the necessary environment
variables are set, either log in again, or type

. $p

in your shell.
EOF
fi
33 changes: 33 additions & 0 deletions scripts/nix-profile.fish.in
@@ -0,0 +1,33 @@
if [ -n "$HOME" ] && [ -n "$USER" ]

# Set up the per-user profile.
# This part should be kept in sync with nixpkgs:nixos/modules/programs/shell.nix

set -l NIX_LINK $HOME/.nix-profile

# Set up environment.
# This part should be kept in sync with nixpkgs:nixos/modules/programs/environment.nix
set -gx NIX_PROFILES "@localstatedir@/nix/profiles/default $HOME/.nix-profile"

# Set $NIX_SSL_CERT_FILE so that Nixpkgs applications like curl work.
if [ -e /etc/ssl/certs/ca-certificates.crt ] # NixOS, Ubuntu, Debian, Gentoo, Arch
set -gx NIX_SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt
else if [ -e /etc/ssl/ca-bundle.pem ] # openSUSE Tumbleweed
set -gx NIX_SSL_CERT_FILE /etc/ssl/ca-bundle.pem
else if [ -e /etc/ssl/certs/ca-bundle.crt ] # Old NixOS
set -gx NIX_SSL_CERT_FILE /etc/ssl/certs/ca-bundle.crt
else if [ -e /etc/pki/tls/certs/ca-bundle.crt ] # Fedora, CentOS
set -gx NIX_SSL_CERT_FILE /etc/pki/tls/certs/ca-bundle.crt
else if [ -e "$NIX_LINK/etc/ssl/certs/ca-bundle.crt" ] # fall back to cacert in Nix profile
set -gx NIX_SSL_CERT_FILE "$NIX_LINK/etc/ssl/certs/ca-bundle.crt"
else if [ -e "$NIX_LINK/etc/ca-bundle.crt" ] # old cacert in Nix profile
set -gx NIX_SSL_CERT_FILE "$NIX_LINK/etc/ca-bundle.crt"
end

if [ -n "$MANPATH" ]; then
set -gx --prepend MANPATH "$NIX_LINK/share/man"
end

set -gx --prepend PATH "$NIX_LINK/bin"
set -e NIX_LINK
end