unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* set environment variables with guix shell [-m manifest.scm]
@ 2022-05-05  0:53 Kenny Ballou
  2022-05-05  2:29 ` Kenny Ballou
  2022-05-05  9:05 ` zimoun
  0 siblings, 2 replies; 4+ messages in thread
From: Kenny Ballou @ 2022-05-05  0:53 UTC (permalink / raw)
  To: help-guix


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!:


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-06 22:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05  0:53 set environment variables with guix shell [-m manifest.scm] Kenny Ballou
2022-05-05  2:29 ` Kenny Ballou
2022-05-05  9:05 ` zimoun
2022-05-06 22:20   ` Kenny Ballou

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).