Environment Variables and Eshell Part 2 (publ. 2024-09-25)

Didn't mean to make this a two part post, but I ran out of lunch-break time yesterday.

Anyways, I see that the emacs-guix interface has a "shell" menu, which presumably mirrors "guix shell" functionality in some way, but it is broken at present. I have submitted a bug report. It also has a "set Emacs environment" command, but it does not seem to be quite what I am looking for. You pass it the path to a profile, and it supposedly makes the emacs environment match that profile. So, conceivably I could build the profile with guix shell, and then pass the $GUIX_ENVIRONMENT to the "set Emacs environment" command.

Presumably I could also use the emacs-guix REPL to get a list of environment variables and then set those in Eshell, but I would need to do a lot more research to get there, for the correct syntax and such.

An approach which seemed in principle to be very simple was to just use the run "*guix shell <arguments> -- env" within eshell, get the environment variables outputted, and then set them within eshell. In practice, there a lot of nuances to this which make it a difficult affair, such as capturing the correct output and sourcing the variables correctly. Eventually, I was able to get there, however, with this eshell script:

The prefix-exports function is as follows:

So I can, e.g., call

I get the error about the variables because those are built-in variables in Eshell, and are therefore cannot be set (unlike in bash). But the other variables are set, so it still works. Notice that I used a call to "bash -c" in the second line of the script, as a means of getting the env output redirected into a file without getting it mixed up with the status output from "guix shell".

Not saying this is the best approach, but it works in a hackish way. Perhaps I will have time in the future to explore some other approach.

This work © 2024 by Christopher Howard is licensed under Attribution-ShareAlike 4.0 International.

CC BY-SA 4.0 Deed

Proxied content from gemini://gem.librehacker.com/gemlog/starlog/20240925-0.gmi

Gemini request details:

Original URL
gemini://gem.librehacker.com/gemlog/starlog/20240925-0.gmi
Status code
Success
Meta
text/gemini
Proxied by
kineto

Be advised that no attempt was made to verify the remote SSL certificate.