In the getting started documentation (and in daviwil’s article) I can see that:
1- I should set my GUIX_PROFILE path (usually to the default $HOME/.guix-profile) and source the $GUIX_PROFILE/etc/profile so all env vars are well set and pointing to my packages (e.g in the default profile). These lines are added to .bash_profile also.
2- But also, the first time I run guix pull, the documentations sayd after that I should change the GUIX_PROFILE path - since the freshest guix instance is elsewhere in .config/guix/current, and source from there the env vars (etc/profile). Finally, it is said these two lines should be added to bash_profile.
I don’t get why in the second step I should add these lines to bash_profile:
now in my bash profile I have 2 competing/colliding definitions of GUIX_PROFILE and of course the second one overrides the first.
Shouldn’t I choose which profile I want to use by default?
Isn’t the new guix command that was just pulled by guix pull to be pointed only once for the guix upgrade?
Finally I would understand if I temporarily misdirect the GUIX_PROFILE variable to .config/guix/current, e.g by inserting the two lines in my shell, but I do not get why these lines should go into bash_profile.
PATH already contains both $HOME/.guix-profile and $HOME/.config/guix/current, both are set by /etc/profile.d/zzz.guix.sh.
$GUIX_PROFILE/etc/profile prepends $GUIX_PROFILE/bin to PATH, giving it “higher priority”.
I can’t really test what was guix first install path, but I guess this first setting for guix pull is linked to that (I might check in the guix-install.sh).
Anyway it all comes to where the guix command is located, and where PATH lookups first.
I prefer not really adding the .config/guix/current in my bash_profile, but I’ll see on other guix pull if I really need to. I guess also putting both values of GUIX_PROFILE in .bash_profile but current first and default next (or your profile of choice) would be another good default for me.
Heads up, I’m actually starting the usage of guix in my workflow, and using only as package manager, so I’m also not 100% sure on what I’ll say.
As far as I understood, the default “$HOME/.guix-profile” is where the packages are installed when using guix package. The “$HOME/.config/guix/current” is where the latest pulled repository information is saved as well as the latest guix binary, that is updated with a guix pull.
That’s why the “$HOME/.config/guix/current/bin” should be the highest priority in PATH, to use the latest guix, and the default profile the “$HOME/.guix-profile”, where the installed packages are.
When starting out with guix this was very confusing to me. It seems that GUIX_PROFILE is just a variable that is used to source the profiles.
Here is my bash_profile. As you can see I’m using extra profiles, GUIX_PROFILE is used to source each one and then it is set to .guix-profile to source it. Previously in .profile guix home sources its own profile in setup-environment.
# Set up the system, user profile, and related variables.
# /etc/profile will be sourced by bash automatically
# Set up the home environment profile.
if [ -z "$XDG_RUNTIME_DIR" ]; then
XDG_RUNTIME_DIR="/tmp/$(id -u)-runtime-dir"
mkdir -pm 0700 "$XDG_RUNTIME_DIR"
export XDG_RUNTIME_DIR
fi
if [ -f ~/.profile ]; then
source ~/.profile;
fi
# Honor per-interactive-shell startup file
if [ -f ~/.bashrc ]; then
source ~/.bashrc;
fi
PS1='\u@\h \w${GUIX_ENVIRONMENT:+ [env]}\$ '
export GUIX_EXTRA_PROFILES="$HOME/.guix-extra-profiles"
# Source extra profiles
for i in $GUIX_EXTRA_PROFILES/*; do
profile=$i/$(basename "$i")
if [ -f "$profile"/etc/profile ]; then
GUIX_PROFILE="$profile"
. "$GUIX_PROFILE"/etc/profile
fi
unset profile
done
# Source guix-profile
export GUIX_PROFILE=~/.guix-profile
. $GUIX_PROFILE/etc/profile
[ "$(tty)" = "/dev/tty1" ] && exec sway -d