From: Kenny Ballou <kb@devnulllabs.io>
To: help-guix@gnu.org
Subject: set environment variables with guix shell [-m manifest.scm]
Date: Wed, 04 May 2022 18:53:47 -0600 [thread overview]
Message-ID: <87tua4kcoh.fsf@devnulllabs.io> (raw)
Dear list,
I have been using nix-shell for a while now to have on-demand/ad-hoc
development environments for different projects. These are hooked in
with direnv and the whole experience is quite nice. However, I would
like to translate these to Guix because I find the tooling around Guix
and Scheme far better and easier.
However, one necessary feature of `guix shell` I'm not seeing: ability
to set arbitrary environment variables when `guix shell` loads.
Certainly, I thought I could just add some `(setenv "FOO" "bar")` in the
`manifest.scm` file. But if the environment is reloaded, these
statements do not seem to persist.
For example, I've been working on a manifest for my current main
project, it has the following, elided for brevity, contents:
```
(define z3-with-java
(package
(inherit z3)
...))
(let ((z3-dir (run-with-store (open-connection)
(package-file z3-with-java))))
(setenv "LD_LIBRARY_PATH" (string-append z3-dir "/lib"))
(setenv "Z3_DIR" z3-dir))
(packages->manifest
(list openjdk11
...
z3-with-java))
```
Perhaps, this is not the right way to do this? Is there a different
mechanism I am not aware of? Would this be a good extension to `guix
shell` manifests?
This would not be an issue if I did not need the store path of the
package. I could simply set the environment variables in the `.envrc`
file. However, I still think it would be preferable to have a mechanism
for setting environment variables via `guix shell` similar to `nix
shell`.
Thoughts?
My gratitude in advance.
-Kenny
--
:SIG:!0xB0CAA28A02958308!:
next reply other threads:[~2022-05-05 4:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 0:53 Kenny Ballou [this message]
2022-05-05 2:29 ` set environment variables with guix shell [-m manifest.scm] Kenny Ballou
2022-05-05 9:05 ` zimoun
2022-05-06 22:20 ` Kenny Ballou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tua4kcoh.fsf@devnulllabs.io \
--to=kb@devnulllabs.io \
--cc=help-guix@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).