宋文武 <iyzsong@gmail.com> skribis:
> Or better to generate a 'profile' script for each manifest, and then
> merged in shell level, so it can work out-of-the-box. How about:
> - /etc/profile:
> # configuration for the whole system goes here.
> # shouldn't refer profile paths.
> export LANG=en_US.utf8
> export SSL_CERT_DIR=/etc/ssl/certs
> export LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules
> [...]
>
> source /run/current-system/profile/etc/profile
>
> if [ -f $HOME/.guix-profile/etc/profile ]; then
> source $HOME/.guix-profile/etc/profile
> fi
>
> # honor setuid-programs
> export PATH=/run/setuid-programs:$PATH
>
> - /run/current-system/profile/etc/profile:
> export PATH=/run/current-system/profile/bin:/run/current-system/profile/sbin:$PATH
> export MANPATH=/run/current-system/profile/share/man:$PATH
> [...]
>
> - ~/.guix-profile/etc/profile:
> export PATH=~/.guix-profile/bin:~/.guix-profile/sbin:$PATH
> [...]
There’s a further complication here: ‘profile-derivation’, which builds
the profile, doesn’t know its user-visible name ~/.guix-profile. It
just knows its store file name. However, we don’t want etc/profile to
read:
export PATH=/gnu/store/...-profile/bin:$PATH
because then, the user’s environment variables in a running session
would keep pointing to a given profile generation.
So we have to tell ‘profile-generation’ what the user-visible name of
the profile is going to be. Attached is a very rough patch to do that.
This is not so nice because all user interfaces will now have to pass
that #:target parameter or etc/profile will be “wrong.”
Another option would be to simply run:
eval `guix package -p ~/.guix-profile --search-paths`
This has two downsides:
1. It takes ~200 ms to run on my laptop, which can maybe be
noticeable; OTOH it’s only for interactive shells, so maybe that’s
OK.
2. If there’s a manifest format change and /etc/profile calls a ‘guix’
command that cannot handle the manifest format (because it’s older
than the ‘guix’ used to build the profile), then it doesn’t work at
all (that’s a bit contrived, but not completely impossible.)
Thoughts?
Ludo’.
Debbugs is free software and licensed under the terms of the
GNU Public License version 2. The current version can be
obtained from https://bugs.debian.org/debbugs-source/.