guix-devel
[Top][All Lists]
Advanced

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

Export environment variables only in `guix environment`.


From: Fis Trivial
Subject: Export environment variables only in `guix environment`.
Date: Mon, 29 Jan 2018 22:29:09 +0000

* Problem
The exported environment variables can cause various problems in foreign
distribution(1)(2). And besides, The long list of environment variables(4)
injected into user's login shell makes the user's environment impure.
So, I believe that if I want to run guix safely on a foreign distributions, I
need to eliminate the need for exporting environment variables from guix to my
login shell.

* From nix
I tried nix and found that they actually don't export any library related
environment variable by default, the only non-prefixed env in their profile file
is $PATH, so the above mentioned problem cannot arise on the nix side. But the
simple solution isn't perfect either.  In short, one cannot access any library
installed by nix without launching `nix-shell`(much like `guix environment`).
Even worse, you need to specify all the needed libraries before launching it,
which is extremely inconvenient, especially when you use interpreters like
python shell. That's not good for Unix, where casual programming is a daily
practice.
Around the problem, they also have some discussions, for details, please refer
to(1).

So, I am thinking if we can come to a middle land, that we *ONLY* source those
exported environment variables when launching `guix environment` or
`guix container`, and let the behavior controllable by command arguments. For
example:
`guix environment --export-all-envs`
 or
`guix environment --export GI_TYPELIB_PATH`


[1]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30093
[2]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30229
[3]: https://github.com/NixOS/nixpkgs/issues/10597

[4]: The envs exported by guix on my system, copied from 
~/.guix-profile/etc/profile

export 
PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/bin:${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/sbin${PATH:+:}$PATH"
export 
C_INCLUDE_PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/include${C_INCLUDE_PATH:+:}$C_INCLUDE_PATH"
export 
CPLUS_INCLUDE_PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/include${CPLUS_INCLUDE_PATH:+:}$CPLUS_INCLUDE_PATH"
export 
LIBRARY_PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/lib:${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/lib64${LIBRARY_PATH:+:}$LIBRARY_PATH"
export 
XDG_DATA_DIRS="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/share${XDG_DATA_DIRS:+:}$XDG_DATA_DIRS"
export 
GIO_EXTRA_MODULES="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/lib/gio/modules${GIO_EXTRA_MODULES:+:}$GIO_EXTRA_MODULES"
export 
GI_TYPELIB_PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/lib/girepository-1.0${GI_TYPELIB_PATH:+:}$GI_TYPELIB_PATH"
export 
PYTHONPATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/lib/python3.5/site-packages${PYTHONPATH:+:}$PYTHONPATH"
export 
GUIX_GTK3_PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/lib/gtk-3.0${GUIX_GTK3_PATH:+:}$GUIX_GTK3_PATH"
export 
PERL5LIB="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/lib/perl5/site_perl${PERL5LIB:+:}$PERL5LIB"
export 
GUILE_LOAD_PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/share/guile/site/2.2${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
export 
GUILE_LOAD_COMPILED_PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/share/guile/site/2.2${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
export 
CMAKE_PREFIX_PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/${CMAKE_PREFIX_PATH:+:}$CMAKE_PREFIX_PATH"
export 
PKG_CONFIG_PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/lib/pkgconfig:${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/share/pkgconfig${PKG_CONFIG_PATH:+:}$PKG_CONFIG_PATH"
export 
CPATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/include${CPATH:+:}$CPATH"
export 
SSL_CERT_DIR="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/etc/ssl/certs${SSL_CERT_DIR:+:}$SSL_CERT_DIR"
export 
GHC_PACKAGE_PATH="${GUIX_PROFILE:-/gnu/store/5myb7fcfvlmcxb2yw1kra70603ma56fm-profile}/lib/ghc-8.0.2/package.conf.d${GHC_PACKAGE_PATH:+:}$GHC_PACKAGE_PATH"



reply via email to

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