Subject: Re: bug#56661: EMACSLOADPATH not set when using Guix System + Guix Home + SLIM + Mate

From: Andrew Tropin <[email-masked]>
Date: Wed, 20 Jul 2022 20:47:21 +0300

On 2022-07-20 14:30, Maxime Devos wrote:

> On 20-07-2022 14:08, Andrew Tropin wrote:
>> Hi Maxime,
>>
>> According to the documentation to get all the environment variables set
>> correctly you either need to manage your login shell with Guix Home or
>> do additional configuration of your shell:
>> https://guix.gnu.org/manual/devel/en/html_node/Configuring-the-Shell.html
>
> I am not using a login shell, though I suppose there might be one under 
> the hood somewhere (IIRC, and if it hasn't changed, some login managers 
> are wrapped in Guix System to insert a bash --login in-between). Even if 
> I am using a (non-login) shell, there's still an issue: if I start an 
> application via the graphical things, they don't get all the environment 
> variables (I tested this by opening a terminal that starts bash and 
> doing "echo $EMACSLOADPATH", but that a shell is used for the test seems 
> irrelevant here to me).
>
>>  From what I see you manage bash with Guix Home,
> I am not. I just keep the default ~/.bash_profile etc that a fresh Guix 
> System install gave me and the only reason bash_profile things appear in 
> the home configuration is because "guix home import" generated that. I'm 
> not managing anything, just keeping the defaults.

You are ;) Declaring home-bash-service-type in home environment means
that Guix Home will generate and install bash configurations, which
means you are managing bash configurations with Guix Home.

>> so according to the
>> source code your bash_profile should look differently from what you've
>> posted and must contain `source ~/.profile` in it:
>
> ~/.bash_profile does contain that line:
>
> # Set up the system, user profile, and related variables.
> # /etc/profile will be sourced by bash automatically
> # Set up the home environment profile.
> if [ -f ~/.profile ]; then source ~/.profile; fi
>
> # Honor per-interactive-shell startup file
> if [ -f ~/.bashrc ]; then source ~/.bashrc; fi
> # Honor per-interactive-shell startup file
> if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

You can remove your original bash_profile, because it's just duplicates
last two lines, Guix Home adds the same content as skeletons provided
during system installation and a little more.

>
> However, .bash_profile (the one from the local-file) does not:
>
> # Honor per-interactive-shell startup file
> if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
>
>
>> https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/home/services/shells.scm#n440
>>
>> This line makes your login shell
>
> I am not using a login shell but a graphical environment -- the only 
> reason I actually use a shell at all is because I find it more 
> convenient to open a terminal and type "emacs" than to look in the 
> graphical desktop thingy for the Emacs icon. Also, I'm not finding Emacs 
> here even though in the previous installation of Guix System (GDM + Mate 
> IIRC, without Guix Home but with "guix install ...".  Icedove isn't 
> appearing there either, though the browser is.
>
> I recall that it login shells were not necessary on Guix System + 
> ~/.guix-profile (without Guix Home), at least for the desktop 
> environment combination I used back then, though it was required on my 
> Debian system to do "bash --login".  I can do "bash --login" on my Guix 
> System + Guix Home setup to start a login shell, but that would be a 
> regression.
>

I'm not sure how your login/display manager works, but for X11 session
sourcing ~/.profile from ~/.xsession should do the trick.

Put the following content to your ~/.xsession:
--8<---------------cut here---------------start------------->8---
. ~/.profile
--8<---------------cut here---------------end--------------->8---

Or add the following service to your home environment:
--8<---------------cut here---------------start------------->8---
(simple-service
 'xsession-init-file
 home-files-service-type
 `((".xsession" ,(plain-file "xsession" ". ~/.profile"))))
--8<---------------cut here---------------end--------------->8---

>>   source .profile, which sources
>> setup-environment, which sources ~/.guix-home/profile/etc/profile, which
>> sets EMACSLOADPATH.
>>
>> Additionally, I've built the home environment you provided and it
>> contains the code I mentioned above.
>>
>> Make sure that ~/.bash_profile and ~/.guix-home/files/.bash_profile
>> point to the same file in the store.
>
> antipode@antipode ~$ ls -l .bash_profile
> lrwxrwxrwx 1 antipode users 56 19 jul 22:14 .bash_profile -> 
> /gnu/store/1cq87qf8zccxlnkjwifcyhawmxvy7wfw-bash_profile
>
> antipode@antipode ~$ ls -l ~/.guix-home/files/.bash_profile
> lrwxrwxrwx 1 root root 56  1 jan  1970 
> /home/antipode/.guix-home/files/.bash_profile -> 
> /gnu/store/1cq87qf8zccxlnkjwifcyhawmxvy7wfw-bash_profile
>
> They do.  Also, shouldn't ~/.bash_profile point to 
> ~/.guix-home/files/.bash_profile instead of directly to the store, to be 
> more atomic (unrelated to #56661 though), like done for symlinks in /etc 
> in Guix System?

No.

Activation is not atomic process anyway.

-- 
Best regards,
Andrew Tropin