guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting environment variables in a profile


From: Théo Maxime Tyburn
Subject: Setting environment variables in a profile
Date: Thu, 19 May 2022 21:43:12 +0200
User-agent: mu4e 1.6.10; emacs 28.0.90

Hi,

I would like some environement variables to be present whenever I enter
a shell using `guix shell -p ...`.
Is there an easy way to do this?
I tried it this way: in the manifest file I use to define the
profile, I define a package and set some
(native)-search-paths. Unfortunatly this It didn’t work for some
reason I ignore. The environment variables are not there when I enter
the shell or source the profile directly. Here is the code

--8<---------------cut here---------------start------------->8---
(define my-env
  (package
   (version "0")    
   (source #f)
   (build-system trivial-build-system)
   (arguments '(#:builder (mkdir %output)))
   (synopsis "Empty package")
   (description
    "This package creates its store directory and nothing more.")
   (home-page #f)
   (license license:gpl3+)
   (name "my-env")
   (native-search-paths
    (list (search-path-specification
           (variable "PYTHONPATH")
           (files '("/home/teddd/..."
                    "/home/teddd/..."
                    "/home/teddd/...")))
          (search-path-specification
           (variable "BLENDER_USER_CONFIG")
           (files '("...")))
          (search-path-specification
           (variable "BLENDER_OPTIONS")
           (files '("--python-use-system-env")))
          ))
   (arguments '(#:builder (mkdir %output)))
   ))
--8<---------------cut here---------------end--------------->8---

Another problem I would have with this method is that the last environment
variable I want to set (BLENDER_OPTIONS) is not even a path. I am not
sure it is possible to sepcify a file-type to be "just a string".
Anyway I think this seems to be the wrong approach.

How would you approach this?

I konw direnv and other utils to set environment variables exist, I
miself use a bash script to initialize my profiles with variables I
want. But it would just be much more convinient to be able to define arbitrary 
env
variables in a guix manifest and enter a shell with everything you need.

Best,

Théo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]