Hi Guix, The Guix Cookbook chapter "Guix Profiles in Practice" [1] advises that, when one activates a profile generated from a manifest, environment variables like MANPATH won't be set automatically unless the packages that will consume them (in this case man-db) was also included in the manifest. There seems to be a Guix command tailor-made for solving this problem: `guix package --search-paths`. I am wondering if it would make sense to recommend that as the default way to ensure MANPATH, etc. are set correctly. I have had success replacing the cookbook's recommended boilerplate in my .profile with: eval \ $(eval guix package --search-paths=prefix \ -p /run/current-system/profile \ $(for p in $(guix package --list-profiles); do echo -n " -p '$p'" done) \ $(for p in $GUIX_EXTRA_PROFILES/*; do echo -n " -p '$p/$(basename "$p")'" done)) which on my system means: guix package --search-paths=prefix \ -p /run/current-system/profile \ -p ~/.config/guix/current \ -p ~/.guix-profile \ -p $GUIX_EXTRA_PROFILES/abc/abc \ -p $GUIX_EXTRA_PROFILES/xyz/zyz # etc. This properly sets the manpath etc., as the consuming packages (man-db and friends) are present in the included "built-in" profiles (first 3 `-p` arguments listed above). The only caveat I'm aware of is that the multiple `guix` invocations aren't instantaneous, so one might not want to use this if sourcing their .profile from .bashrc or equivalent, as it would add some init time to every shell invocation. Is this a safe solution? Is there ever a reason to explicitly source the `etc/profile` file of a profile as the cookbook currently recommends, rather than getting at its contents via `--search-paths`? Put another way, could a profile's `etc/profile` ever include setup code that `--search-paths` would miss? Thanks, Jacob [1]: https://guix.gnu.org/cookbook/en/html_node/Guix-Profiles-in-Practice.html
[-- Attachment #1: Type: text/plain, Size: 1101 bytes --] hot12shots <hot12shots@gmail.com> wrote: > guix package --search-paths=prefix \ > -p /run/current-system/profile \ > -p ~/.config/guix/current \ > -p ~/.guix-profile \ > -p $GUIX_EXTRA_PROFILES/abc/abc \ > -p $GUIX_EXTRA_PROFILES/xyz/zyz > # etc. > > This properly sets the manpath etc., as the consuming packages (man-db and friends) are present in the included "built-in" profiles (first 3 `-p` arguments listed above). Ha! Nice trick, thanks. Alas, it wonʼt help much on top of foreign distribution, where they often are not. > The only caveat I'm aware of is that the multiple `guix` invocations aren't instantaneous, so one might not want to use this if sourcing their .profile from .bashrc or equivalent, as it would add some init time to every shell invocation. But one should never source profiles from ~/.bashrc in any case! They are supposed to sourced by login shell only. In other words, there is ~/.profile (or ~/.bash_profile) for that. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 247 bytes --]
On Tue, Aug 4, 2020 at 5:01 PM Dmitry Alexandrov <dag@gnui.org> wrote: > Alas, it wonʼt help much on top of foreign distribution, where they often are not. True, good point! On Guix native systems I've discovered another problem as well: the PATH assignment output by `--search-paths=prefix` can mask /run/setuid-programs by prepending other path items in front of them, so PATH has to be fixed manually after applying this change to ensure sudo etc. don't break. > > The only caveat I'm aware of is that the multiple `guix` invocations aren't instantaneous, so one might not want to use this if sourcing their .profile from .bashrc or equivalent, as it would add some init time to every shell invocation. > > But one should never source profiles from ~/.bashrc in any case! They are supposed to sourced by login shell only. In other words, there is ~/.profile (or ~/.bash_profile) for that. It's definitely a nonstandard usage, but I think some people do it. More simply, though, one might want to have .bashrc just activate the extra Guix profiles, without sourcing .profile. This would be a workaround to avoid having to restart the login session in order to get access to newly activated profiles in a shell environment.