[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
set environment variables with guix shell [-m manifest.scm]
From: |
Kenny Ballou |
Subject: |
set environment variables with guix shell [-m manifest.scm] |
Date: |
Wed, 04 May 2022 18:53:47 -0600 |
User-agent: |
mu4e 1.6.10; emacs 28.1.50 |
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!:
- set environment variables with guix shell [-m manifest.scm],
Kenny Ballou <=